2021-01-29 02:40:52 +02:00
|
|
|
const http = require('http');
|
|
|
|
|
2021-01-26 12:04:53 +02:00
|
|
|
const Wormhole = require('../index');
|
|
|
|
|
2021-01-29 02:40:52 +02:00
|
|
|
const httpServer = http.createServer();
|
|
|
|
|
|
|
|
const wormhole = new Wormhole({ urls: [ '/hello' ], httpServer });
|
|
|
|
|
|
|
|
wormhole.on('connect', ({ socket, accept, reject }) => {
|
|
|
|
accept();
|
2021-02-03 19:55:41 +02:00
|
|
|
const buf = Buffer.from([0x41, 0x41, 0x41, 0x41]);
|
|
|
|
console.log(buf);
|
|
|
|
socket.send(buf);
|
|
|
|
socket.on('text', console.log);
|
2021-01-29 02:40:52 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
httpServer.listen(8080);
|