Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const WebSocket = require('ws');
- const ElapsedTime = require('elapsed-time')
- var elapsed;
- const headers = {
- authorization: "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6Ijc5MjYxOTM1MDA1IiwidXNlcl91dWlkIjoiNWY0NzkyOTItYmZhMC00MmZlLWJkNGItZjlmZmIyMjNhZjRmIiwiZXhwIjoxNTQ1Mjk5Mzk0LCJvcmlnX2lhdCI6MTU0MjcwNzM5NH0.I-fbcMx4vGDOBLLpXAAFafP6EBVUXOw2pEDHUwIf09g"
- };
- //const ws = new WebSocket('ws://socket.limonapp.com/ws/', {headers: headers});
- const ws = new WebSocket('ws://dev.limonapp.com:8080/ws/', {headers: headers});
- //const ws = new WebSocket('ws://localhost:8080/ws/', {headers: headers});
- ws.on('open', function open() {
- elapsed = ElapsedTime.new().start();
- console.log('Connection opened');
- var a = {
- "event": "IM_ALIVE",
- "point": {
- "type": "Point",
- "coordinates": [55.33, 33.55]
- }
- };
- ws.send(JSON.stringify(a));
- });
- ws.on('close', function open() {
- console.log('Connection error')
- });
- ws.on('close', function open() {
- console.log('Connection closed after ' + elapsed.getValue())
- });
- ws.on('message', function incoming(data) {
- console.log(data);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement