internal Task <TResponse> SendRequestAndWaitResponse <TResponse>(RequestBase request) where TResponse : ResponseBase { Interlocked.Increment(ref _lastToken); request.Token = _lastToken; var requestBytes = _serializer.Serialize(request); var command = new Command(CommandNames.Request, requestBytes); return(_requestsHandler.WaitForResponse <TResponse>(request, () => _transport.SendData(_commandParser.ToBytes(command)))); }
public Command Create <T>(CommandName name, T body) { string bodyString = _dtoSerializer.Serialize(body); return(new Command(name, bodyString) { UserId = _userIdprovider.UserId }); }
public void Send <T>(T obj) where T : class { try { Logger.Trace("SEND ({1}): {0}", obj.GetType().Name, GetSessionName()); var objBytes = _serializer.Serialize(obj); var cmd = CommandNames.Data; if (obj is ResponseBase) { cmd = CommandNames.Response; } if (obj is RequestBase) { cmd = CommandNames.Request; } var commandBytes = _commandParser.ToBytes(cmd, objBytes); _performanceMeasurer.HandleOutgoingBytes(commandBytes.LongLength); Send(commandBytes, 0, commandBytes.Length); } catch (Exception exc) { Logger.Exception(exc, "Tried to send {0} to {1}", obj == null ? "NULL" : obj.GetType().Name, GetSessionName()); //TODO: log } }
public string Serialize(Command cmd) { return(_innerSerializer.Serialize(cmd)); }