simplify message parsing

pull/702/head
Luke Pulverenti 10 years ago
parent 5060cd3b82
commit 98992ca580

@ -65,9 +65,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
void socket_OnMessage(object sender, SocketHttpListener.MessageEventArgs e) void socket_OnMessage(object sender, SocketHttpListener.MessageEventArgs e)
{ {
if (OnReceive != null) if (OnReceiveBytes != null)
{ {
OnReceiveBytes(e.RawData); OnReceiveBytes(e.RawData);
//OnReceive(e.Data);
} }
} }

@ -1,4 +1,5 @@
using MediaBrowser.Common.Events; using System.Text;
using MediaBrowser.Common.Events;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
@ -122,23 +123,22 @@ namespace MediaBrowser.Server.Implementations.ServerManager
} }
try try
{ {
WebSocketMessageInfo info; //_logger.Debug(Encoding.UTF8.GetString(bytes));
using (var memoryStream = new MemoryStream(bytes)) using (var memoryStream = new MemoryStream(bytes))
{ {
var stub = (WebSocketMessage<object>)_jsonSerializer.DeserializeFromStream(memoryStream, typeof(WebSocketMessage<object>)); var info = (WebSocketMessageInfo)_jsonSerializer.DeserializeFromStream(memoryStream, typeof(WebSocketMessageInfo));
info = new WebSocketMessageInfo
{
MessageType = stub.MessageType,
Data = stub.Data == null ? null : stub.Data.ToString()
};
}
//info = new WebSocketMessageInfo
//{
// MessageType = stub.MessageType,
// Data = stub.Data == null ? null : stub.Data.ToString()
//};
info.Connection = this; info.Connection = this;
OnReceive(info); OnReceive(info);
} }
}
catch (Exception ex) catch (Exception ex)
{ {
_logger.ErrorException("Error processing web socket message", ex); _logger.ErrorException("Error processing web socket message", ex);

Loading…
Cancel
Save