|
@@ -118,7 +118,16 @@ public class WebSocketServer {
|
|
|
public static int sendMessage(String sid, String message) {
|
|
|
Session session = SESSION_MAP.get(sid);
|
|
|
if (null == session) {
|
|
|
- return ExceptionEnum.NULL_POINTER.getCode();
|
|
|
+ String userid = sid.split("-")[0];
|
|
|
+ for (Map.Entry<String, Session> entry : SESSION_MAP.entrySet()) {
|
|
|
+ if (entry.getKey().startsWith(userid)) {
|
|
|
+ session = entry.getValue();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null == session) {
|
|
|
+ return ExceptionEnum.NULL_POINTER.getCode();
|
|
|
+ }
|
|
|
}
|
|
|
try {
|
|
|
session.getBasicRemote().sendText(message);
|