up
This commit is contained in:
@@ -75,6 +75,8 @@ namespace Dist.SpringWebsocket
|
||||
try
|
||||
{
|
||||
this.socket = new ClientWebSocket();
|
||||
//socket.Options.SetBuffer(4096, 4096);
|
||||
socket.Options.AddSubProtocol("stomp");
|
||||
socket.ConnectAsync(new Uri(url), CancellationToken.None).Wait();
|
||||
socket_Opened(this);
|
||||
|
||||
@@ -102,7 +104,16 @@ namespace Dist.SpringWebsocket
|
||||
var result = await client.ReceiveAsync(arraySegment, CancellationToken.None);
|
||||
while (!result.CloseStatus.HasValue)
|
||||
{
|
||||
if (result.MessageType == WebSocketMessageType.Text)
|
||||
if (result.MessageType == WebSocketMessageType.Binary)
|
||||
{
|
||||
if (isDebug)
|
||||
{
|
||||
string msg = Encoding.UTF8.GetString(array, 0, result.Count);
|
||||
Debug.Log("receive:" + result.Count + "==\n" + msg);
|
||||
}
|
||||
socket_MessageReceived(client, array, result.Count);
|
||||
}
|
||||
else if (result.MessageType == WebSocketMessageType.Text)
|
||||
{
|
||||
if (isDebug)
|
||||
{
|
||||
@@ -132,6 +143,10 @@ namespace Dist.SpringWebsocket
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e);
|
||||
if (socket != null)
|
||||
{
|
||||
Debug.LogError(this.socket.CloseStatusDescription);
|
||||
}
|
||||
socket_Error(this, e.ToString());
|
||||
}
|
||||
}
|
||||
@@ -172,6 +187,10 @@ namespace Dist.SpringWebsocket
|
||||
{
|
||||
isSending = false;
|
||||
Debug.LogError(e);
|
||||
if (socket != null)
|
||||
{
|
||||
Debug.LogError(this.socket.CloseStatusDescription);
|
||||
}
|
||||
socket_Error(this, e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user