Tlantic / cdv-socket-plugin

Cordova Socket Plugin
GNU General Public License v3.0
51 stars 43 forks source link

Socket receive method listen only once. #73

Closed linjackson78 closed 9 years ago

linjackson78 commented 9 years ago

There's no problem useing your plugin for connect(), send(), but for receive(), here comes the problem: Seems like it can listen correctly only once. After logging the first messages, the callback I set was no more called again. Here's my simplified code.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady (){
    document.addEventListener(window.tlantic.plugins.socket.receiveHookName, function (ev) {
      console.log(ev.metadata.data)
    }
}

In fact there's a timeout set to my server. When timeout the connection will be closed. And only until then, all messages sent by my server was received and logged.

Log-in succeed. controllers.js:77
WELCOME: You have 1 unread messages.WELCOME: You have 1 unread messages.WELCOME: You have 1 unread messages. controllers.js:77

I have another client app written in go-lang working well with my server. So I am wondering: What's the right way to use your plugin to receive tcp-socket message?

Note: I am using ionic, and all these code are embedded in a controller.

linjackson78 commented 9 years ago

Finally, it's angular's problem. No $digest on socket event. Sorry bothering.