private void OnMessage(object sender, MessageEventArgs e) { if (!e.IsBinary) { return; } var data = e.RawData; var bytesRead = e.RawData.Length; if (bytesRead <= 0) { return; } var eve = new SocketEvent { Data = data }; onMessage(eve); return; }
private void OnMessageEvent(SocketEvent socketEvent) { if (socketEvent.Data.Length == 0) { return; } var resData = socketEvent.Data; var msgWrap = UnpackBody(socketEvent.Data); switch (msgWrap.Pre) { case (byte)MessageDataTag.ClientPre when(byte) MessageDataTag.ClientEnd == msgWrap.End: _handleResponse(msgWrap.Body); break; case (byte)MessageDataTag.ServerPre when(byte) MessageDataTag.ServerEnd == msgWrap.End: _handleBroadcast(msgWrap.Body); break; } }