mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
24 lines
575 B
TypeScript
24 lines
575 B
TypeScript
import Primus = require('primus');
|
|
|
|
const primus = Primus.createServer({
|
|
transformer: 'websockets',
|
|
});
|
|
|
|
primus.on('connection', function connection(spark) {
|
|
spark.on('data', function received(data) {
|
|
spark.write(data);
|
|
});
|
|
});
|
|
|
|
const Socket = Primus.createSocket();
|
|
const client = new Socket('ws://www.example.com');
|
|
|
|
client.on('open', () => {
|
|
client.write('foo');
|
|
});
|
|
|
|
client.on('reconnect scheduled', (opts) => {
|
|
console.log('Reconnecting in %d ms', opts.scheduled);
|
|
console.log('This is attempt %d out of %d', opts.attempt, opts.retries);
|
|
});
|