Advertisement
Guest User

socket.io.d.ts

a guest
Jan 25th, 2013
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. declare module "socket.io" {
  2.     export var version : string;
  3.     export var protocol: number;
  4.     export var clientVersion : string;
  5.     export function listen(server : any, options? : ManagerOptions, fn?) : Manager;
  6.  
  7.     export interface Manager {
  8.         constructor (server, options : ManagerOptions);
  9.         server : any;
  10.         namespaces;
  11.         sockets : SocketNamespace;
  12.         settings : ManagerOptions;
  13.         store;
  14.         log;
  15.         static;
  16.         get(key);
  17.         set(key, value);
  18.         enable(key);
  19.         disable(key);
  20.         enabled(key);
  21.         disabled(key);
  22.         configure(env, fn);
  23.         //initStore();
  24.         //onHandshake(id, data);
  25.         //onConnect(id);
  26.         //onOpen(id);
  27.         //onDispatch(room, packet, volatile, exceptions);
  28.         //onJoin(id, name);
  29.         //onLeave(id, room);
  30.         //onClose(id);
  31.         //onClientDispatch(id, packet);
  32.         //onClientMessage(id, packet);
  33.         //onClientDisconnect(id, reason);
  34.         //onDisconnect(id, reason);
  35.         //handleRequest(req, res);
  36.         //handleUpgrade(req, socket, head);
  37.         //handleHTTPRequest(data, req, res);
  38.         //handleClient(data, req);
  39.         //generateId();
  40.         //handleHandshake(data, req, res);
  41.         //handshakeData(data);
  42.         //verifyOrigin(request);
  43.         //handlePacket(sessid, packet);
  44.         //authorize(data, fn);
  45.         //transports(data);
  46.         //checkRequest(req);
  47.         of(nsp);
  48.         //garbageCollection();
  49.     }
  50.  
  51.     export interface SocketNamespace extends EventEmitter {
  52.         manager;
  53.         name;
  54.         sockets;
  55.         auth: bool;
  56.         clients(room) : any[];
  57.         log;
  58.         store;
  59.         json : bool;
  60.         volatile: bool;
  61.         in(room) : SocketNamespace;
  62.         to(room) : SocketNamespace;
  63.         except(id) : SocketNamespace;
  64.         //setFlags(): SocketNamespace;
  65.         //packet(packet): SocketNamespace;
  66.         send(data: any): SocketNamespace;
  67.         socket(sid, readable?);
  68.         authorization(fn): SocketNamespace;
  69.         // handleDisconnect(sid, reason, raiseOnDisconnect);
  70.         // authorize(data, fn)
  71.         // handlePacket(sessid, packet)
  72.         //
  73.     }
  74.  
  75.     export interface Socket extends EventEmitter {
  76.         id;
  77.         namespace : SocketNamespace;
  78.         manager : Manager;
  79.         disconnected : bool;
  80.         ackPackets: number;
  81.         acks: any;
  82.         readable: bool;
  83.         store;
  84.         handshake;
  85.         transport;
  86.         log: bool;
  87.         json: bool;
  88.         volatile: Socket;
  89.         broadcast : Socket;
  90.         in(room) : SocketNamespace;
  91.         to(room) : SocketNamespace;
  92.         //setFlags();
  93.         //onDisconnect(reason)
  94.         join(name, fn) : Socket;
  95.         leave(name, fn) : Socket;
  96.         //packet(packet);
  97.         //dispatch(packet, volatile);
  98.         set(key, value, fn) : Socket;
  99.         get(key, fn) : Socket;
  100.         has(key, fn) : Socket;
  101.         del(key, fn) : Socket;
  102.         disconnect() : Socket;
  103.         send(data, fn) : Socket;
  104.         on(name: string, callback : Function) : Socket;
  105.         emit(name, ...arguments: any[]) : Socket;
  106.     }
  107.  
  108.     export interface StoreClient {
  109.         store : Store;
  110.         id;
  111.  
  112.         //get(key, fn);
  113.         //set(key, value, fn);
  114.         //has(key, fn);
  115.         //del(key, fn);
  116.         //destroy(expiration);
  117.     }
  118.  
  119.     export interface Store extends EventEmitter {
  120.         constructor (options);
  121.         client(id) : StoreClient;
  122.         destroyClient(id, expiration);
  123.         destroy(expiration);
  124.  
  125.         //publish();
  126.         //subscribe();
  127.         //unsubscribe();
  128.     }
  129.  
  130.     export interface MemoryStore extends Store { }
  131.     export interface RedisStore extends Store {
  132.         constructor (opts: RedisStoreOptions);
  133.     }
  134.  
  135.     export interface Transport {
  136.     }
  137.  
  138.     export interface Static {
  139.     }
  140.  
  141.     export interface parser {
  142.     }
  143.  
  144.     export interface RedisStoreOptions {
  145.         nodeId?: Function;  // (fn) gets an id that uniquely identifies this node
  146.         redis?: Function;  // (fn) redis constructor, defaults to redis
  147.         redisPub?: any;  // (object) options to pass to the pub redis client
  148.         redisSub?: any;  // (object) options to pass to the sub redis client
  149.         redisClient?: any;  // (object) options to pass to the general redis client
  150.         pack?: Function; // (fn) custom packing, defaults to JSON or msgpack if installed
  151.         unpack?: Function; // (fn) custom packing, defaults to JSON or msgpack if installed
  152.     }
  153.  
  154.     export interface ManagerOptions {
  155.         origins?; // : '*:*'
  156.         log?; // : true
  157.         store? : Store; // : new MemoryStore;
  158.         logger?; // : new Logger
  159.         static?;// : new Static(this)
  160.         heartbeats?;// : true
  161.         resource?;// : '/socket.io'
  162.         transports?;// : defaultTransports
  163.         authorization?;//: false
  164.         blacklist?;//: ['disconnect']
  165.         //'log level'?;//: 3
  166.         //'log colors'?;//: tty.isatty(process.stdout.fd)
  167.         //'close timeout'?;//: 60
  168.         //'heartbeat interval'?;//: 25
  169.         //'heartbeat timeout'?;//: 60
  170.         //'polling duration'?;//: 20
  171.         //'flash policy server'?;//: true
  172.         //'flash policy port'?;//: 10843
  173.         //'destroy upgrade'?;//: true
  174.         //'destroy buffer size'?;//: 10E7
  175.         //'browser client'?;//: true
  176.         //'browser client cache'?;//: true
  177.         //'browser client minification'?;//: false
  178.         //'browser client etag'?;//: false
  179.         //'browser client expires'?;//: 315360000
  180.         //'browser client gzip'?;//: false
  181.         //'browser client handler'?;//: false
  182.         //'client store expiration'?;//: 15
  183.         //'match origin protocol'?;//: false
  184.     }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement