mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #1702 from v3rm0n/socketio-client
socket.io nodejs client
This commit is contained in:
@@ -235,6 +235,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.connect('http://localhost:80');
|
||||
|
||||
socket.on('connect', function () {
|
||||
console.log('Connected!');
|
||||
socket.emit('event', 'some test data', function () {
|
||||
console.log('Sent some data.');
|
||||
});
|
||||
});
|
||||
+33
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user