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 });
|
|
|
|
|
2021-03-25 20:24:43 +02:00
|
|
|
wormhole.on('connect', ({ connectingSocket, accept, reject }) => {
|
|
|
|
const socket = accept();
|
|
|
|
socket.send(Buffer.from(new Array(1000000)));
|
2021-02-04 16:01:14 +02:00
|
|
|
socket.on('text', (e) => {
|
2021-03-25 20:24:43 +02:00
|
|
|
console.log('Got text frame', e);
|
2021-02-04 16:01:14 +02:00
|
|
|
});
|
2021-03-25 20:24:43 +02:00
|
|
|
socket.on('binary', (e) => {
|
|
|
|
console.log('Got binary frame', e);
|
2021-02-04 16:01:14 +02:00
|
|
|
});
|
2021-01-29 02:40:52 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
httpServer.listen(8080);
|