feat: add 1.8.8 reflect & export io namespace
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
@ -1,3 +1,46 @@
|
||||
/// <reference types="@ms/nashorn" />
|
||||
|
||||
export * from './socket-io'
|
||||
import { Server, ServerOptions } from './socket-io'
|
||||
|
||||
interface SocketIOStatic {
|
||||
/**
|
||||
* Default Server constructor
|
||||
*/
|
||||
(): Server;
|
||||
|
||||
/**
|
||||
* Creates a new Server
|
||||
* @param srv The HTTP server that we're going to bind to
|
||||
* @param opts An optional parameters object
|
||||
*/
|
||||
(srv: any, opts?: ServerOptions): Server;
|
||||
|
||||
/**
|
||||
* Creates a new Server
|
||||
* @param port A port to bind to, as a number, or a string
|
||||
* @param An optional parameters object
|
||||
*/
|
||||
(port: string | number, opts?: ServerOptions): Server;
|
||||
|
||||
/**
|
||||
* Creates a new Server
|
||||
* @param A parameters object
|
||||
*/
|
||||
(opts: ServerOptions): Server;
|
||||
|
||||
/**
|
||||
* Backwards compatibility
|
||||
* @see io().listen()
|
||||
*/
|
||||
listen?: SocketIOStatic;
|
||||
}
|
||||
|
||||
type SocketStatic = SocketIOStatic & { Instance?: symbol }
|
||||
|
||||
// @ts-ignore
|
||||
let io: SocketStatic = function (pipeline: any, options: ServerOptions) {
|
||||
return new Server(pipeline, options)
|
||||
}
|
||||
io.Instance = Symbol("@ms/websocket")
|
||||
export default io
|
||||
export * from './socket-io'
|
||||
|
@ -15,6 +15,8 @@ export enum Keys {
|
||||
Default = "DefaultChannelPipeline"
|
||||
}
|
||||
|
||||
let RequestAttributeKey: any
|
||||
try { RequestAttributeKey = AttributeKey.valueOf('request') } catch (error) { }
|
||||
export enum AttributeKeys {
|
||||
Request = AttributeKey.valueOf('request')
|
||||
}
|
||||
Request = RequestAttributeKey
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ class NettyWebSocketServer extends EventEmitter {
|
||||
ctx.fireChannelRead(channel)
|
||||
})
|
||||
connectEvent.on(ServerEvent.connect, (ctx) => {
|
||||
console.log('NettyWebSocketServer ServerEvent.connect', ctx, ctx.channel().id(), ctx.channel().class.name)
|
||||
let nettyClient = new NettyClient(this, ctx.channel());
|
||||
this.allClients[nettyClient.id] = nettyClient;
|
||||
this.emit(ServerEvent.connect, nettyClient);
|
||||
|
Reference in New Issue
Block a user