21 lines
No EOL
525 B
JavaScript
21 lines
No EOL
525 B
JavaScript
const http = require('http');
|
|
|
|
const Wormhole = require('../index');
|
|
|
|
const httpServer = http.createServer();
|
|
|
|
const wormhole = new Wormhole({ urls: [ '/hello' ], httpServer });
|
|
|
|
wormhole.on('connect', ({ socket, accept, reject }) => {
|
|
accept();
|
|
const buf = Buffer.from([0x41, 0x41, 0x41, 0x41]);
|
|
socket.send(buf);
|
|
socket.on('text', (e) => {
|
|
//console.log('Got text frame', e);
|
|
});
|
|
socket.on('binary', () => {
|
|
//console.log('Got binary frame', e);
|
|
});
|
|
});
|
|
|
|
httpServer.listen(8080); |