/** 在UI在用js调用websocket.send()时候,会调用该方法 */
 @Override
 protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
   super.handleTextMessage(session, message);
   ArrayList<Long> userIdList = new ArrayList<Long>();
   userIdList.add(999L); // 特定用户发送成功
   sendMessageToUsers(userIdList, message);
 }
 @Override
 protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
   super.handleTextMessage(session, message);
   TextMessage returnMessage = new TextMessage(message.getPayload() + " received at server");
   session.sendMessage(returnMessage);
 }
Example #3
0
 @Override
 protected void handleBinaryMessage(WebSocketSession arg0, BinaryMessage arg1) {
   // TODO Auto-generated method stub
   super.handleBinaryMessage(arg0, arg1);
 }