blocshop/sockets-for-cordova

How we get response

Opened this issue · 1 comments

Hi,

my socket like below
`//scoket send data to machine
$scope.taskName = $rootScope.task_name;
$scope.flightName = $rootScope.flight_name;

                var socket=new Socket();
                socket.open("192.168.4.1",80,function(){
                    console.log("success");

                   var dataString = ""+$scope.flightName+",test,"+$scope.taskName+","+$scope.start_time+",start";
                   var data = new Uint8Array(dataString.length);
                   for (var i = 0; i < data.length; i++) {
                     data[i] = dataString.charCodeAt(i);
                   }
                   socket.write(data,function(res){alert("Data send Successfully")},function(err){console.log(err);alert(err)});
                },function(error){alert(error)});
                socket.shutdownWrite();
                socket.close();`
  1. First it successfully connect the socket.
  2. Now i am able to send write the msg.
  3. How can i get response ?
    socket.write(data,function(res){alert("Data send Successfully")},function(err){console.log(err);alert(err)});
    in this line i print res. But it is showing only ok.

socket.onData = function(data) {
// invoked after new batch of data is received (typed array of bytes Uint8Array)
};