feat: export server & client
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
48cc6325b8
commit
df1646dc15
@ -45,3 +45,7 @@ let io: SocketStatic = function (pipeline: any, options: Partial<ServerOptions>)
|
|||||||
io.Instance = Symbol("@ccms/websocket")
|
io.Instance = Symbol("@ccms/websocket")
|
||||||
export default io
|
export default io
|
||||||
export * from './socket-io'
|
export * from './socket-io'
|
||||||
|
export * from './client'
|
||||||
|
export * from './netty'
|
||||||
|
export * from './tomcat'
|
||||||
|
export * from './transport'
|
||||||
|
@ -65,6 +65,5 @@ class NettyWebSocketServer extends EventEmitter {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
NettyWebSocketServer,
|
NettyWebSocketServer,
|
||||||
ServerEvent,
|
|
||||||
NettyClient
|
NettyClient
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ export class Client extends EventEmitter {
|
|||||||
*
|
*
|
||||||
* @api private
|
* @api private
|
||||||
*/
|
*/
|
||||||
resetPingTimeout(timeout) {
|
resetPingTimeout(timeout: number) {
|
||||||
clearTimeout(this.pingTimeoutTimer)
|
clearTimeout(this.pingTimeoutTimer)
|
||||||
this.pingTimeoutTimer = setTimeout(() => {
|
this.pingTimeoutTimer = setTimeout(() => {
|
||||||
if (this.conn.readyState === "closed") return
|
if (this.conn.readyState === "closed") return
|
||||||
|
@ -5,9 +5,7 @@ import { ServerEvent } from '../socket-io/constants'
|
|||||||
import { ProxyBeanName } from './constants'
|
import { ProxyBeanName } from './constants'
|
||||||
import { TomcatClient } from './client'
|
import { TomcatClient } from './client'
|
||||||
|
|
||||||
const WebSocketServerProxy = Java.type("pw.yumc.MiaoScript.websocket.WebSocketProxy")
|
|
||||||
const ThreadPoolExecutor = Java.type('java.util.concurrent.ThreadPoolExecutor')
|
const ThreadPoolExecutor = Java.type('java.util.concurrent.ThreadPoolExecutor')
|
||||||
const ThreadPoolTaskExecutor = Java.type('org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor')
|
|
||||||
|
|
||||||
type TomcatWebSocketSession = javax.websocket.Session
|
type TomcatWebSocketSession = javax.websocket.Session
|
||||||
|
|
||||||
@ -22,7 +20,7 @@ class TomcatWebSocketServer extends EventEmitter {
|
|||||||
this.beanFactory = beanFactory
|
this.beanFactory = beanFactory
|
||||||
this.initThreadPool()
|
this.initThreadPool()
|
||||||
try { this.beanFactory.destroySingleton(ProxyBeanName) } catch (error) { }
|
try { this.beanFactory.destroySingleton(ProxyBeanName) } catch (error) { }
|
||||||
let NashornWebSocketServerProxy = Java.extend(WebSocketServerProxy, {
|
let NashornWebSocketServerProxy = Java.extend(Java.type("pw.yumc.MiaoScript.websocket.WebSocketProxy"), {
|
||||||
onOpen: (session: TomcatWebSocketSession) => {
|
onOpen: (session: TomcatWebSocketSession) => {
|
||||||
let cid = `${session?.getId()}`
|
let cid = `${session?.getId()}`
|
||||||
let tomcatClient = new TomcatClient(this, session)
|
let tomcatClient = new TomcatClient(this, session)
|
||||||
@ -58,6 +56,7 @@ class TomcatWebSocketServer extends EventEmitter {
|
|||||||
this.beanFactory.registerSingleton(ProxyBeanName, new NashornWebSocketServerProxy())
|
this.beanFactory.registerSingleton(ProxyBeanName, new NashornWebSocketServerProxy())
|
||||||
}
|
}
|
||||||
private initThreadPool() {
|
private initThreadPool() {
|
||||||
|
const ThreadPoolTaskExecutor = Java.type('org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor')
|
||||||
this.executor = new ThreadPoolTaskExecutor()
|
this.executor = new ThreadPoolTaskExecutor()
|
||||||
this.executor.setCorePoolSize(10)
|
this.executor.setCorePoolSize(10)
|
||||||
this.executor.setMaxPoolSize(100)
|
this.executor.setMaxPoolSize(100)
|
||||||
@ -76,6 +75,5 @@ class TomcatWebSocketServer extends EventEmitter {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
TomcatWebSocketServer,
|
TomcatWebSocketServer,
|
||||||
ServerEvent,
|
|
||||||
TomcatClient
|
TomcatClient
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user