diff --git a/socket.io-client/socket.io-client-commonjs-tests.ts b/socket.io-client/legacy/socket.io-client-0.9-commonjs-tests.ts
similarity index 81%
rename from socket.io-client/socket.io-client-commonjs-tests.ts
rename to socket.io-client/legacy/socket.io-client-0.9-commonjs-tests.ts
index 7b5f96747..beb8f0fad 100644
--- a/socket.io-client/socket.io-client-commonjs-tests.ts
+++ b/socket.io-client/legacy/socket.io-client-0.9-commonjs-tests.ts
@@ -1,10 +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.');
- });
-});
+import io = require('socket.io-client-0.9');
+
+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.');
+ });
+});
diff --git a/socket.io-client/legacy/socket.io-client-0.9-tests.ts b/socket.io-client/legacy/socket.io-client-0.9-tests.ts
new file mode 100644
index 000000000..717830628
--- /dev/null
+++ b/socket.io-client/legacy/socket.io-client-0.9-tests.ts
@@ -0,0 +1,10 @@
+///
+
+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.');
+ });
+});
diff --git a/socket.io-client/legacy/socket.io-client-0.9.d.ts b/socket.io-client/legacy/socket.io-client-0.9.d.ts
new file mode 100644
index 000000000..0b3626e42
--- /dev/null
+++ b/socket.io-client/legacy/socket.io-client-0.9.d.ts
@@ -0,0 +1,40 @@
+// Type definitions for socket.io nodejs client
+// Project: http://socket.io/
+// Definitions by: Maido Kaara
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module "socket.io-client-0.9" {
+ export = io;
+}
+
+declare var io: SocketIOStatic;
+
+interface SocketIOStatic {
+ connect(host: string, details?: any): SocketIOClient.Socket;
+}
+
+declare module SocketIOClient {
+ 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;
+ }
+}
diff --git a/socket.io-client/socket.io-client-tests.ts b/socket.io-client/socket.io-client-tests.ts
index e1022c61a..215932c46 100644
--- a/socket.io-client/socket.io-client-tests.ts
+++ b/socket.io-client/socket.io-client-tests.ts
@@ -1,10 +1,57 @@
///
-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.');
+function testUsingWithNodeHTTPServer() {
+ var socket = io('http://localhost');
+ socket.on('news', function (data: any) {
+ console.log(data);
+ socket.emit('my other event', { my: 'data' });
});
-});
+}
+
+function testUsingWithExpress() {
+ var socket = io.connect('http://localhost');
+ socket.on('news', function (data: any) {
+ console.log(data);
+ socket.emit('my other event', { my: 'data' });
+ });
+}
+
+function testUsingWithTheExpressFramework() {
+ var socket = io.connect('http://localhost');
+ socket.on('news', function (data: any) {
+ console.log(data);
+ socket.emit('my other event', { my: 'data' });
+ });
+}
+
+function testRestrictingYourselfToANamespace() {
+ var chat = io.connect('http://localhost/chat')
+ , news = io.connect('http://localhost/news');
+
+ chat.on('connect', function () {
+ chat.emit('hi!');
+ });
+
+ news.on('news', function () {
+ news.emit('woot');
+ });
+}
+
+function testSendingAndGettingData() {
+ var socket = io();
+ socket.on('connect', function () {
+ socket.emit('ferret', 'tobi', function (data: any) {
+ console.log(data);
+ });
+ });
+}
+
+function testUsingItJustAsACrossBrowserWebSocket() {
+ var socket = io('http://localhost/');
+ socket.on('connect', function () {
+ socket.emit('hi');
+
+ socket.on('message', function (msg: any) {
+ });
+ });
+}
diff --git a/socket.io-client/socket.io-client.d.ts b/socket.io-client/socket.io-client.d.ts
index 079ca7cbb..b03cc830b 100644
--- a/socket.io-client/socket.io-client.d.ts
+++ b/socket.io-client/socket.io-client.d.ts
@@ -1,40 +1,46 @@
-// Type definitions for socket.io nodejs client
+// Type definitions for socket.io-client 1.2.0
// Project: http://socket.io/
-// Definitions by: Maido Kaara
+// Definitions by: PROGRE
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-declare module "socket.io-client" {
- export = io;
+///
+
+declare var io: SocketIOClientStatic;
+
+declare module 'socket.io-client' {
+ export = io;
}
-declare var io: SocketIOStatic;
-
-interface SocketIOStatic {
+interface SocketIOClientStatic {
+ (host: string, details?: any): SocketIOClient.Socket;
+ (details?: any): SocketIOClient.Socket;
connect(host: string, details?: any): SocketIOClient.Socket;
+ connect(details?: any): SocketIOClient.Socket;
+ protocol: number;
+ Socket: { new (...args: any[]): SocketIOClient.Socket };
+ Manager: SocketIOClient.ManagerStatic;
}
declare module SocketIOClient {
- 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 Socket {
+ on(event: string, fn: Function): Socket;
+ once(event: string, fn: Function): Socket;
+ off(event: string, fn: Function): Socket;
+ emit(event: string, ...args: any[]): Socket;
+ listeners(event: string): Function[];
+ hasListeners(event: string): boolean;
}
- interface SocketNamespace extends EventEmitter {
- of(name: string): SocketNamespace;
- send(data: any, fn: Function): SocketNamespace;
- emit(name: string): SocketNamespace;
+ interface ManagerStatic {
+ (url: string, opts: any): SocketIOClient.Manager;
+ new (url: string, opts: any): SocketIOClient.Manager;
}
- interface Socket extends EventEmitter {
- of(name: string): SocketNamespace;
- connect(fn: Function): Socket;
- packet(data: any): Socket;
- flushBuffer(): void;
- disconnect(): Socket;
+ interface Manager {
+ reconnection(v: boolean): Manager;
+ reconnectionAttempts(v: boolean): Manager;
+ reconnectionDelay(v: boolean): Manager;
+ reconnectionDelayMax(v: boolean): Manager;
+ timeout(v: boolean): Manager;
}
}