forked from yinxin630/fiora
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add koa-socket-2 ts declaration
- Loading branch information
Showing
4 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules/ | |
dist/ | ||
static/ | ||
public/ | ||
*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// 声明来源: https://github.com/ambelovsky/koa-socket-2/issues/16 | ||
|
||
declare module 'koa-socket-2' { | ||
import { ServerOptions as HttpsServerOptions } from 'https'; | ||
import Application from 'koa'; | ||
import { RouterContext } from 'koa-router'; | ||
import { ServerOptions as SocketioServerOptions } from 'socket.io'; | ||
|
||
interface IOptions { | ||
namespace?: string; | ||
hidden?: boolean; | ||
ioOptions?: SocketioServerOptions; | ||
} | ||
|
||
type IEventHandler = (ctx: RouterContext) => any; | ||
|
||
class IO { | ||
public opts: IOptions; | ||
public connections: Map<string, any>; | ||
// tslint:disable-next-line:variable-name | ||
private _io: any; | ||
private middleware: any[]; | ||
private composed: any; | ||
private listeners: Map<string, any>; | ||
private socket: any; | ||
|
||
constructor(opts: undefined | string | IOptions); | ||
public attach(app: Application, https?: boolean, opts?: HttpsServerOptions): void; | ||
public attachNamespace(app: Application, id: string): void; | ||
public use(fn: any): this; | ||
public on(event: string, handler: IEventHandler): this; | ||
public off(event: string, handler: IEventHandler): this; | ||
public broadcast(event: string, data: any): void; | ||
public to(room: string): object; | ||
private onConnection(sock: any): void; | ||
private onDisconnect(sock: any): void; | ||
private updateConnections(): void; | ||
} | ||
|
||
export = IO; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters