Class SocketHandler

java.lang.Object
org.springframework.web.socket.handler.AbstractWebSocketHandler
org.springframework.web.socket.handler.TextWebSocketHandler
api.log.socket.SocketHandler
All Implemented Interfaces:
org.springframework.web.socket.WebSocketHandler

@Component("alogSocketHandler") public class SocketHandler extends org.springframework.web.socket.handler.TextWebSocketHandler
WebSocket处理器
Author:
chenenwei
  • Constructor Summary

    Constructors
    Constructor
    Description
    构造方法
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterConnectionClosed(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus status)
    连接关闭
    void
    afterConnectionEstablished(org.springframework.web.socket.WebSocketSession session)
    连接建立
    protected void
    handleTextMessage(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.TextMessage message)
    处理消息
    void
    sendToClient(org.springframework.web.socket.WebSocketSession session, String message)
    发送消息到客户端

    Methods inherited from class org.springframework.web.socket.handler.TextWebSocketHandler

    handleBinaryMessage

    Methods inherited from class org.springframework.web.socket.handler.AbstractWebSocketHandler

    handleMessage, handlePongMessage, handleTransportError, supportsPartialMessages

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SocketHandler

      public SocketHandler()
      构造方法
  • Method Details

    • afterConnectionEstablished

      public void afterConnectionEstablished(org.springframework.web.socket.WebSocketSession session)
      连接建立
      Specified by:
      afterConnectionEstablished in interface org.springframework.web.socket.WebSocketHandler
      Overrides:
      afterConnectionEstablished in class org.springframework.web.socket.handler.AbstractWebSocketHandler
      Parameters:
      session - session
    • afterConnectionClosed

      public void afterConnectionClosed(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus status) throws Exception
      连接关闭
      Specified by:
      afterConnectionClosed in interface org.springframework.web.socket.WebSocketHandler
      Overrides:
      afterConnectionClosed in class org.springframework.web.socket.handler.AbstractWebSocketHandler
      Parameters:
      session - session
      status - 状态
      Throws:
      Exception - 异常
    • handleTextMessage

      protected void handleTextMessage(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.TextMessage message) throws Exception
      处理消息
      Overrides:
      handleTextMessage in class org.springframework.web.socket.handler.AbstractWebSocketHandler
      Parameters:
      session - session
      message - 消息
      Throws:
      Exception - 异常
    • sendToClient

      public void sendToClient(org.springframework.web.socket.WebSocketSession session, String message)
      发送消息到客户端
      Parameters:
      session - session
      message - 消息