|
|
@ -43,7 +43,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
ws.OnMessage += (s, e) => |
|
|
|
ws.OnMessage += (s, e) => |
|
|
|
{ |
|
|
|
{ |
|
|
|
string content = Encoding.UTF8.GetString(e.Content); |
|
|
|
string content = Encoding.UTF8.GetString(e.Content); |
|
|
|
if (content != "ping") |
|
|
|
//读取参数 |
|
|
|
|
|
|
|
if (content != "ping" && !string.IsNullOrEmpty(content)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//返回内容 |
|
|
|
//返回内容 |
|
|
|
string result = string.Empty; |
|
|
|
string result = string.Empty; |
|
|
@ -140,6 +141,18 @@ namespace AKS.EnterpriseLibrary.WebBrowser |
|
|
|
byte[] bytes = SerializeContent(result); |
|
|
|
byte[] bytes = SerializeContent(result); |
|
|
|
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes)); |
|
|
|
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//监听心跳并且回复客户端“已ping作为关键字” |
|
|
|
|
|
|
|
else if (content == "ping") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"收到客户端心跳\"}"; |
|
|
|
|
|
|
|
byte[] bytes = SerializeContent(result); |
|
|
|
|
|
|
|
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
string result = "{\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"收到客户端心跳\"}"; |
|
|
|
|
|
|
|
byte[] bytes = SerializeContent(result); |
|
|
|
|
|
|
|
ws.Reply(s.ToString(), new SAEA.WebSocket.Model.WSProtocal(SAEA.WebSocket.Type.WSProtocalType.Text, bytes)); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
ws.OnDisconnected += (s) => |
|
|
|
ws.OnDisconnected += (s) => |
|
|
|
{ |
|
|
|
{ |
|
|
|