1
嗨,我想在我与离子这一个应用程序中使用的WebSockets学习:https://www.npmjs.com/package/cordova-plugin-websocket和我复制下面的例子:科尔多瓦的WebSocket
var ws = new WebSocket('ws://echo.websocket.org');
$scope.sendMessage = function(){
ws.send('test');
};
ws.onopen = function() { alert('open'); };
ws.onmessage = function (event) {
alert(event.data);
};
ws.onerror = function() { alert('error occurred!'); };
ws.onclose = function (event) { alert('close code=' + event.code); };
这似乎是确定的,但如果连接中断如何我可以重新连接吗?我如何才能为我的所有应用程序制作这个功能?
在先进的感谢
哦,上帝,我在想我会忘记http,但这种方式我必须忘记websockets,谢谢埃里克。 –
不用担心,但请确认我的答案,如果你不介意的话...... – Eric