remove socket.io/legacy and socket.io-client/legacy

This commit is contained in:
vvakame
2015-08-29 00:11:17 +09:00
parent f9e262a035
commit 1321ffbee6
10 changed files with 0 additions and 500 deletions
@@ -1,10 +0,0 @@
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.');
});
});
@@ -1,10 +0,0 @@
/// <reference path="socket.io-client-0.9.d.ts"/>
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.');
});
});
-40
View File
@@ -1,40 +0,0 @@
// 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-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;
}
}
@@ -1,57 +0,0 @@
/// <reference path="socket.io-client-1.2.0.d.ts"/>
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) {
});
});
}
-45
View File
@@ -1,45 +0,0 @@
// Type definitions for socket.io-client 1.2.0
// Project: http://socket.io/
// Definitions by: PROGRE <https://github.com/progre/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare var io: SocketIOClientStatic;
declare module 'socket.io-client' {
export = io;
}
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 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;
connected: boolean;
}
interface ManagerStatic {
(url: string, opts: any): SocketIOClient.Manager;
new (url: string, opts: any): SocketIOClient.Manager;
}
interface Manager {
reconnection(v: boolean): Manager;
reconnectionAttempts(v: boolean): Manager;
reconnectionDelay(v: boolean): Manager;
reconnectionDelayMax(v: boolean): Manager;
timeout(v: boolean): Manager;
}
}
-24
View File
@@ -1,24 +0,0 @@
import io = require('socket.io-0.9');
var socketManager = io.listen(80);
socketManager.sockets.on('connection', socket => {
socket.emit('news', { hello: 'world' });
socket.on('my other event', data => {
console.log(data);
});
});
// Storing data Associated to a client.
// Server side sample
io.listen(80).sockets.on('connection', function (socket) {
socket.on('set nickname', function (name) {
socket.set('nickname', name, function () { socket.emit('ready'); });
});
socket.on('msg', function () {
socket.get('nickname', function (err, name) {
console.log('Chat message by ', name);
});
});
});
@@ -1 +0,0 @@
-70
View File
@@ -1,70 +0,0 @@
// Type definitions for socket.io
// Project: http://socket.io/
// Definitions by: William Orr <https://github.com/worr>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path='../../node/node.d.ts' />
declare module "socket.io-0.9" {
import http = require('http');
export function listen(server: http.Server, options: any, fn: Function): SocketManager;
export function listen(server: http.Server, fn?: Function): SocketManager;
export function listen(port: Number): SocketManager;
interface Socket {
id: string;
json:any;
log: any;
volatile: any;
broadcast: any;
handshake: any;
in(room: string): Socket;
to(room: string): Socket;
join(name: string, fn: Function): Socket;
leave(name: string, fn: Function): Socket;
set(key: string, value: any, fn: Function): Socket;
get(key: string, fn: Function): Socket;
has(key: string, fn: Function): Socket;
del(key: string, fn: Function): Socket;
disconnect(): Socket;
send(data: any, fn: Function): Socket;
emit(ev: any, ...data:any[]): Socket;
on(ns: string, fn: Function): Socket;
}
interface SocketNamespace {
clients(room: string): Socket[];
log: any;
store: any;
json: any;
volatile: any;
in(room: string): SocketNamespace;
on(evt: string, fn: (socket: Socket) => void): SocketNamespace;
to(room: string): SocketNamespace;
except(id: any): SocketNamespace;
send(data: any): any;
emit(ev: any, ...data:any[]): Socket;
socket(sid: any, readable: boolean): Socket;
authorization(fn: Function): SocketNamespace;
}
interface SocketManager {
get(key: any): any;
set(key: any, value: any): SocketManager;
enable(key: any): SocketManager;
disable(key: any): SocketManager;
enabled(key: any): boolean;
disabled(key: any): boolean;
configure(env: string, fn: Function): SocketManager;
configure(fn: Function): SocketManager;
of(nsp: string): SocketNamespace;
on(ns: string, fn: Function): SocketManager;
sockets: SocketNamespace;
}
}
-147
View File
@@ -1,147 +0,0 @@
/// <reference path="socket.io-1.2.0.d.ts"/>
import socketIO = require('socket.io-1.2.0');
function testUsingWithNodeHTTPServer() {
var app = require('http').createServer(handler);
var io = socketIO(app);
var fs = require('fs');
app.listen(80);
function handler(req: any, res: any) {
fs.readFile(__dirname + '/index.html',
function (err: any, data: any) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data: any) {
console.log(data);
});
});
}
function testUsingWithExpress() {
var app = require('express')();
var server = require('http').Server(app);
var io = socketIO(server);
server.listen(80);
app.get('/', function (req: any, res: any) {
res.sendfile(__dirname + '/index.html');
});
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data: any) {
console.log(data);
});
});
}
function testUsingWithTheExpressFramework() {
var app = require('express').createServer();
var io = socketIO(app);
app.listen(80);
app.get('/', function (req: any, res: any) {
res.sendfile(__dirname + '/index.html');
});
io.on('connection', function (socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function (data: any) {
console.log(data);
});
});
}
function testSendingAndReceivingEvents() {
var io = socketIO(80);
io.on('connection', function (socket) {
io.emit('this', { will: 'be received by everyone' });
socket.on('private message', function (from: any, msg: any) {
console.log('I received a private message by ', from, ' saying ', msg);
});
socket.on('disconnect', function () {
io.sockets.emit('user disconnected');
});
});
}
function testRestrictingYourselfToANamespace() {
var io = socketIO.listen(80);
var chat = io
.of('/chat')
.on('connection', function (socket) {
socket.emit('a message', {
that: 'only'
, '/chat': 'will get'
});
chat.emit('a message', {
everyone: 'in'
, '/chat': 'will get'
});
});
var news = io
.of('/news')
.on('connection', function (socket) {
socket.emit('item', { news: 'item' });
});
}
function testSendingVolatileMessages() {
var io = socketIO.listen(80);
io.sockets.on('connection', function (socket) {
var tweets = setInterval(function () {
socket.volatile.emit('bieber tweet', {});
}, 100);
socket.on('disconnect', function () {
clearInterval(tweets);
});
});
}
function testSendingAndGettingData() {
var io = socketIO.listen(80);
io.sockets.on('connection', function (socket) {
socket.on('ferret', function (name: any, fn: any) {
fn('woot');
});
});
}
function testBroadcastingMessages() {
var io = socketIO.listen(80);
io.sockets.on('connection', function (socket) {
socket.broadcast.emit('user connected');
});
}
function testUsingItJustAsACrossBrowserWebSocket() {
var io = socketIO.listen(80);
io.sockets.on('connection', function (socket) {
socket.on('message', function () { });
socket.on('disconnect', function () { });
});
}
-96
View File
@@ -1,96 +0,0 @@
// Type definitions for socket.io 1.2.0
// Project: http://socket.io/
// Definitions by: PROGRE <https://github.com/progre/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path='../../node/node.d.ts' />
declare module 'socket.io-1.2.0' {
var server: SocketIOStatic;
export = server;
}
interface SocketIOStatic {
(): SocketIO.Server;
(srv: any, opts?: any): SocketIO.Server;
(port: number, opts?: any): SocketIO.Server;
(opts: any): SocketIO.Server;
listen: SocketIOStatic;
}
declare module SocketIO {
interface Server {
serveClient(v: boolean): Server;
path(v: string): Server;
adapter(v: any): Server;
origins(v: string): Server;
sockets: Namespace;
attach(srv: any, opts?: any): Server;
attach(port: number, opts?: any): Server;
listen(srv: any, opts?: any): Server;
listen(port: number, opts?: any): Server;
bind(srv: any): Server;
onconnection(socket: any): Server;
of(nsp: string): Namespace;
emit(name: string, ...args: any[]): Socket;
use(fn: Function): Namespace;
on(event: 'connection', listener: (socket: Socket) => void): Namespace;
on(event: 'connect', listener: (socket: Socket) => void): Namespace;
on(event: string, listener: Function): Namespace;
}
interface Namespace extends NodeJS.EventEmitter {
name: string;
connected: { [id: string]: Socket };
use(fn: Function): Namespace;
in(room: string): Namespace;
on(event: 'connection', listener: (socket: Socket) => void): Namespace;
on(event: 'connect', listener: (socket: Socket) => void): Namespace;
on(event: string, listener: Function): Namespace;
}
interface Socket {
rooms: string[];
client: Client;
conn: any;
request: any;
id: string;
handshake: {
headers: any;
time: string;
address: any;
xdomain: boolean;
secure: boolean;
issued: number;
url: string;
query: any;
};
emit(name: string, ...args: any[]): Socket;
join(name: string, fn?: Function): Socket;
leave(name: string, fn?: Function): Socket;
to(room: string): Socket;
in(room: string): Socket;
send(...args: any[]): Socket;
write(...args: any[]): Socket;
on(event: string, listener: Function): Socket;
once(event: string, listener: Function): Socket;
removeListener(event: string, listener: Function): Socket;
removeAllListeners(event: string): Socket;
broadcast: Socket;
volatile: Socket;
connected: boolean;
disconnect(close?: boolean): Socket;
}
interface Client {
conn: any;
request: any;
id: string;
}
}