WebSocket 服务器

var wsServer = 'ws://127.0.0.1:9500';


var websocket = new WebSocket(wsServer);


websocket.onopen = function (evt) {    console.log("Connected to WebSocket server.");

};


websocket.onclose = function (evt) {    console.log("Disconnected");

};


websocket.onmessage = function (evt) {    console.log('Retrieved data from server: ' + evt.data);

};

websocket.onerror = function (evt, e) {

   console.log('Error occured: ' + evt.data);

};

评论 (0)

发表评论

上一篇: sed的用法 下一篇: nrm安装与配置