Advertisement
Guest User

Untitled

a guest
May 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let net = require('net');
  2.  
  3. let server = net.createServer(function (socket) {
  4.  
  5.     socket.on('data', function (data) {
  6.         if(!!data){
  7.              let stringData = toString('utf8').trim();
  8.               if(stringData.length > 0){
  9.                 try{
  10.                   let matchRegex = stringData.match('\{" *livepp_current_pp" *: *"([0-9\.]+)" *\}');
  11.                   if(matchRegex != null && matchRegex.length > 1){
  12.                     console.log(matchRegex[1]);
  13.                   }else{
  14.                     console.warn("could not extract livepp_current_app");
  15.                   }
  16.                  
  17.                 } catch(e){
  18.                   console.error("Unexpected error :"+e+"with stringData :"+stringData);
  19.                 }
  20.               }else{
  21.                 console.warn("empty String received");
  22.               }
  23.  
  24.         }else{
  25.           console.warn("data is null");
  26.         }
  27.     });
  28.  
  29. });
  30.  
  31. server.listen(7840, '0.0.0.0');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement