PageRenderTime 62ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/socket.io/socket.io.d.ts

https://github.com/vilic/DefinitelyTyped
TypeScript Typings | 78 lines | 61 code | 12 blank | 5 comment | 0 complexity | 88361e29c8e0e1ae6c5842ae29c3eeb2 MD5 | raw file
Possible License(s): MIT
  1. // Type definitions for socket.io 1.2.0
  2. // Project: http://socket.io/
  3. // Definitions by: PROGRE <https://github.com/progre/>
  4. // Definitions: https://github.com/borisyankov/DefinitelyTyped
  5. ///<reference path='../node/node.d.ts' />
  6. declare module 'socket.io' {
  7. var server: SocketIOStatic;
  8. export = server;
  9. }
  10. interface SocketIOStatic {
  11. (): SocketIO.Server;
  12. (srv: any, opts?: any): SocketIO.Server;
  13. (port: number, opts?: any): SocketIO.Server;
  14. (opts: any): SocketIO.Server;
  15. listen: SocketIOStatic;
  16. }
  17. declare module SocketIO {
  18. interface Server {
  19. serveClient(v: boolean): Server;
  20. path(v: string): Server;
  21. adapter(v: any): Server;
  22. origins(v: string): Server;
  23. sockets: Namespace;
  24. attach(srv: any, opts?: any): Server;
  25. attach(port: number, opts?: any): Server;
  26. listen(srv: any, opts?: any): Server;
  27. listen(port: number, opts?: any): Server;
  28. bind(srv: any): Server;
  29. onconnection(socket: any): Server;
  30. of(nsp: string): Namespace;
  31. emit(name: string, ...args: any[]): Socket;
  32. use(fn: Function): Namespace;
  33. on(event: 'connection', listener: (socket: Socket) => void): any;
  34. on(event: 'connect', listener: (socket: Socket) => void): any;
  35. on(event: string, listener: Function): any;
  36. }
  37. interface Namespace extends NodeJS.EventEmitter {
  38. name: string;
  39. connected: { [id: string]: Socket };
  40. use(fn: Function): Namespace
  41. on(event: 'connection', listener: (socket: Socket) => void): any;
  42. on(event: 'connect', listener: (socket: Socket) => void): any;
  43. on(event: string, listener: Function): any;
  44. }
  45. interface Socket {
  46. rooms: string[];
  47. client: Client;
  48. conn: Socket;
  49. request: any;
  50. id: string;
  51. emit(name: string, ...args: any[]): Socket;
  52. join(name: string, fn?: Function): Socket;
  53. leave(name: string, fn?: Function): Socket;
  54. to(room: string): Socket;
  55. in(room: string): Socket;
  56. on(event: string, listener: Function): any;
  57. broadcast: Socket;
  58. volatile: Socket;
  59. connected: boolean;
  60. disconnect(close?: boolean): Socket;
  61. }
  62. interface Client {
  63. conn: any;
  64. request: any;
  65. }
  66. }