From 503ca79dabbb191c358b16491c58230eedf6fc46 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Sat, 30 May 2020 10:18:01 +0800 Subject: [PATCH] fix: websocket session send synchronized Signed-off-by: MiaoWoo --- packages/websocket/src/tomcat/client.ts | 2 +- packages/websocket/src/tomcat/server.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/websocket/src/tomcat/client.ts b/packages/websocket/src/tomcat/client.ts index 95d0b270..130fe274 100644 --- a/packages/websocket/src/tomcat/client.ts +++ b/packages/websocket/src/tomcat/client.ts @@ -36,7 +36,7 @@ export class TomcatClient extends EventEmitter implements SocketIO.EngineSocket return this._id; } send(text: string) { - this.session.getBasicRemote().sendText(text) + Java.synchronized(() => this.session.getBasicRemote().sendText(text), this.session)() } close() { this.session.close(); diff --git a/packages/websocket/src/tomcat/server.ts b/packages/websocket/src/tomcat/server.ts index 06b9b9e0..53121142 100644 --- a/packages/websocket/src/tomcat/server.ts +++ b/packages/websocket/src/tomcat/server.ts @@ -6,7 +6,7 @@ import { SocketIO } from '../socket-io/interfaces' import { ProxyBeanName } from './constants' import { TomcatClient } from './client' -const WebSocketServerProxy = Java.type("com.sixi.framework.scriptservice.websocket.WebSocketServerProxy") +const WebSocketServerProxy = Java.type("pw.yumc.MiaoScript.websocket.WebSocketProxy") const ThreadPoolExecutor = Java.type('java.util.concurrent.ThreadPoolExecutor') const ThreadPoolTaskExecutor = Java.type('org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor')