feat: add 1.8.8 reflect & export io namespace
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
d22b72f10a
commit
1c29a059d9
@ -5,6 +5,7 @@ import * as reflect from '@ms/common/dist/reflect'
|
|||||||
import chat from './enhance/chat'
|
import chat from './enhance/chat'
|
||||||
|
|
||||||
const refList: Array<{ server: string, future: string }> = [
|
const refList: Array<{ server: string, future: string }> = [
|
||||||
|
{ server: 'aq', future: 'g' },//spigot 1.8.8
|
||||||
{ server: 'an', future: 'g' },//spigot 1.12.2
|
{ server: 'an', future: 'g' },//spigot 1.12.2
|
||||||
{ server: 'getServerConnection', future: 'f' },//after spigot 1.14.4
|
{ server: 'getServerConnection', future: 'f' },//after spigot 1.14.4
|
||||||
{ server: 'func_147137_ag', future: 'field_151274_e' }//catserver 1.12.2
|
{ server: 'func_147137_ag', future: 'field_151274_e' }//catserver 1.12.2
|
||||||
@ -74,7 +75,7 @@ export class BukkitServer implements server.Server {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!promise) { throw Error(`Can't found ServerConnection or ChannelFuture !`) }
|
if (!promise) { console.error("Can't found ServerConnection or ChannelFuture !"); return }
|
||||||
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
|
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,12 @@ import { attachForge } from './forge'
|
|||||||
import { attachEvents } from './event'
|
import { attachEvents } from './event'
|
||||||
|
|
||||||
let username = process.argv[2] || 'Mr_jtb'
|
let username = process.argv[2] || 'Mr_jtb'
|
||||||
|
let version = process.argv[3] || '1.12.2'
|
||||||
let client = createConnection('192.168.2.5', 25577, username)
|
let client = createConnection('192.168.2.5', 25577, username)
|
||||||
|
|
||||||
function createConnection(host: string, port: number, username: string) {
|
function createConnection(host: string, port: number, username: string) {
|
||||||
let client = createClient({
|
let client = createClient({
|
||||||
version: '1.12.2',
|
version,
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
username,
|
username,
|
||||||
|
@ -1,3 +1,46 @@
|
|||||||
/// <reference types="@ms/nashorn" />
|
/// <reference types="@ms/nashorn" />
|
||||||
|
|
||||||
|
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'
|
export * from './socket-io'
|
@ -15,6 +15,8 @@ export enum Keys {
|
|||||||
Default = "DefaultChannelPipeline"
|
Default = "DefaultChannelPipeline"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let RequestAttributeKey: any
|
||||||
|
try { RequestAttributeKey = AttributeKey.valueOf('request') } catch (error) { }
|
||||||
export enum AttributeKeys {
|
export enum AttributeKeys {
|
||||||
Request = AttributeKey.valueOf('request')
|
Request = RequestAttributeKey
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ class NettyWebSocketServer extends EventEmitter {
|
|||||||
ctx.fireChannelRead(channel)
|
ctx.fireChannelRead(channel)
|
||||||
})
|
})
|
||||||
connectEvent.on(ServerEvent.connect, (ctx) => {
|
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());
|
let nettyClient = new NettyClient(this, ctx.channel());
|
||||||
this.allClients[nettyClient.id] = nettyClient;
|
this.allClients[nettyClient.id] = nettyClient;
|
||||||
this.emit(ServerEvent.connect, nettyClient);
|
this.emit(ServerEvent.connect, nettyClient);
|
||||||
|
Loading…
Reference in New Issue
Block a user