Type definitions for server side nodejs socket.io client.

This commit is contained in:
Maido Käära
2014-02-16 13:51:13 +00:00
parent 654d7e89d0
commit 8265a17569
3 changed files with 44 additions and 0 deletions
+1
View File
@@ -233,6 +233,7 @@ List of Definitions
* [SlickGrid](https://github.com/mleibman/SlickGrid) (by [Josh Baldwin](https://github.com/jbaldwin))
* [smoothie](https://github.com/joewalnes/smoothie) (by [Mike H. Hawley](https://github.com/mikehhawley))
* [socket.io](http://socket.io) (by [William Orr](https://github.com/worr))
* [socket.io-client](http://socket.io) (by [Maido Kaara](https://github.com/v3rm0n))
* [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev))
* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
* [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov))
@@ -0,0 +1,10 @@
import io = require('socket.io-client');
var socket = io('http://localhost:80');
socket.on('connect', function () {
console.log('Connected!');
socket.send('some test data', function () {
console.log('Sent some data.');
});
});
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for socket.io nodejs client
// Project: http://socket.io/
// Definitions by: Maido Kaara <https://github.com/v3rm0n>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "socket.io-client" {
export function connect(host: string, details?: any): Socket;
interface EventEmitter {
emit(name: string, ...data: any[]): any;
on(ns: string, fn: Function): EventEmitter;
addListener(ns: string, fn: Function): EventEmitter;
removeListener(ns: string, fn: Function): EventEmitter;
removeAllListeners(ns: string): EventEmitter;
once(ns: string, fn: Function): EventEmitter;
listeners(ns: string): Function[];
}
interface SocketNamespace extends EventEmitter {
of(name: string): SocketNamespace;
send(data: any, fn: Function): SocketNamespace;
emit(name: string): SocketNamespace;
}
interface Socket extends EventEmitter {
of(name: string): SocketNamespace;
connect(fn: Function): Socket;
packet(data: any): Socket;
flushBuffer(): void;
disconnect(): Socket;
}
}