internal void AppendResponse(byte[] responseData) { try { var response = RequestSerializer.Deserialize <ResponseBase>(responseData); if (response != null) { RequestsHandler.AppendResponse(response); } } catch (Exception exc) { log.ErrorFormat("{0}" + Environment.NewLine + "Tried to recognize {1} bytes as request for {2}", exc.Message, responseData == null ? "NULL" : responseData.Length.ToString(), SessionID); } }
public void Send <T>(T obj) where T : class { try { log.InfoFormat("SEND ({1}): {0}", obj.GetType().Name, SessionID); var objBytes = RequestSerializer.Serialize(obj); var cmd = CommandTypes.Request; if (obj is ResponseBase) { cmd = CommandTypes.Response; } var commandBytes = CommandParser.ToBytes(new Command(cmd, objBytes)); Send(commandBytes, 0, commandBytes.Length); } catch (Exception exc) { log.ErrorFormat("{0}" + Environment.NewLine + "Tried to send {1} to {2}", exc.Message, obj == null ? "NULL" : obj.GetType().Name, SessionID); } }