@Component public class WebSocketServer extends Object
Constructor and Description |
---|
WebSocketServer() |
Modifier and Type | Method and Description |
---|---|
static void |
addOnlineCount() |
static int |
getOnlineCount() |
void |
onClose()
连接关闭调用的方法
|
void |
onError(javax.websocket.Session session,
Throwable error) |
void |
onMessage(String message,
javax.websocket.Session session)
收到客户端消息后调用的方法
|
void |
onOpen(javax.websocket.Session session,
String userId)
连接建立成功调用的方法
|
static void |
sendInfo(String message,
String userId)
群发自定义消息
|
void |
sendMessage(String message)
实现服务器主动推送
|
static void |
subOnlineCount() |
public void onOpen(javax.websocket.Session session, String userId)
public void onClose()
public void onMessage(String message, javax.websocket.Session session)
message
- 客户端发送过来的消息public void onError(javax.websocket.Session session, Throwable error)
session
- error
- public void sendMessage(String message) throws IOException
IOException
public static int getOnlineCount()
public static void addOnlineCount()
public static void subOnlineCount()
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.