Blasto33

index.js tuto web sockets

Jul 14th, 2022
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. import WebSocket from 'ws';
  2.  
  3. const ws = new WebSocket('ws://<your_ngrok_id_here>.ngrok.io');
  4.  
  5. ws.on('open', function open() {
  6. ws.send('something');
  7. });
  8.  
  9. ws.on('message', function message(data) {
  10. console.log('received: %s', data);
  11. });
Advertisement
Add Comment
Please, Sign In to add comment