mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Fixed typescript errors and added tests
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/// <reference path="socketty.d.ts" />
|
||||
|
||||
/* Server */
|
||||
|
||||
var httpServer = {}; // Assume it's a real HTTP server object
|
||||
|
||||
var webSocketServer = socketty.createServer(httpServer);
|
||||
|
||||
webSocketServer.connection((socket: SockettySocket) => {
|
||||
console.log('Client connected');
|
||||
socket.on('msg', (message?: any) => {
|
||||
console.log('Client said' + message);
|
||||
});
|
||||
socket.disconnect(() => {
|
||||
console.log('Goodbye, client!');
|
||||
});
|
||||
});
|
||||
|
||||
/* Client */
|
||||
|
||||
socketty.connect('ws://localhost:8080', (socket: SockettySocket) => {
|
||||
console.log('Connected !');
|
||||
socket.send('msg', 'Hello server!');
|
||||
});
|
||||
Reference in New Issue
Block a user