Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var WebSocket = require('ws');
- var ws = new WebSocket('ws://192.168.0.49:8080');
- ws.on('open', function() {
- console.log('connected');
- var data = {code: "Message", payload: {
- id: "ae31209",
- from: "e2e23f34",
- to: "a439e123",
- text: "A message",
- time_stamp: "blablabla"
- }};
- ws.send(JSON.stringify(data));
- //ws.send(Date.now().toString(), {mask: true});
- });
- ws.on('close', function() {
- console.log('disconnected');
- });
- ws.on('message', function(data, flags) {
- console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags);
- setTimeout(function() {
- ws.send(Date.now().toString(), {mask: true});
- }, 500);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement