/// <summary> /// Reads a single single response from the stream and processes it. /// </summary> /// <param name="stream"></param> private void ProcessResponse(Stream stream) { Response response; long requestId = 0; if (WriteRequestIdInResponse) { byte[] requestIdBytes = new byte[sizeof(long)]; stream.Read(requestIdBytes, 0, requestIdBytes.Length); requestId = BitConverter.ToInt64(requestIdBytes, 0); } byte[] responseTypeBytes = new byte[2]; stream.Read(responseTypeBytes, 0, responseTypeBytes.Length); Response.Type responseType = (Response.Type)BitConverter.ToInt16(responseTypeBytes, 0); //Reading a response's header... byte[] cmdSzBytes = new byte[CmdSizeHolderBytesCount]; stream.Read(cmdSzBytes, 0, CmdSizeHolderBytesCount); int commandSize = HelperFxn.ToInt32(cmdSzBytes, 0, CmdSizeHolderBytesCount); byte[] cmdBytes = new byte[commandSize]; stream.Read(cmdBytes, 0, commandSize); CommandResponse cmdRespose = new CommandResponse(false, new Address()); cmdRespose.CacheId = _cacheId; cmdRespose.Src = this.ServerAddress; if (WriteRequestIdInResponse) { cmdRespose.NeedsDeserialization = true; cmdRespose.RequestId = requestId; cmdRespose.SerializedResponse = cmdBytes; cmdRespose.Type = responseType; } else { using (Stream tempStream = new ClusteredMemoryStream(cmdBytes)) response = ResponseHelper.DeserializeResponse(responseType, tempStream); cmdRespose.NeedsDeserialization = false; if (response != null) { cmdRespose.Result = response; } } if (_perfStatsColl.IsEnabled) { _perfStatsColl.IncrementClientResponsesPerSecStats(1); } if (cmdRespose != null) { _container.ProcessResponse(cmdRespose, _serverAddress); } }
public void OnResponseSend(Response.Type type) { // sends out the response object and event Response r = new Response(type); responseEvent.Invoke(r); responseEvent.RemoveAllListeners(); Close(); }
internal void AddResponse(Common.Net.Address address, CommandResponse response) { _type = response.Type; lock (_responseMutex) { if (_responses.ContainsKey(address)) { ResponseList responseList = _responses[address]; if (!responseList.IsComplete) { responseList.AddResponse(response); } else { if (_reRoutedAddress != null && !_reRoutedAddress.Equals(address)) { if (!_responses.ContainsKey(_reRoutedAddress)) { ResponseList rspList = new ResponseList(); if (!rspList.IsComplete) { rspList.AddResponse(response); } _responses.Add(_reRoutedAddress, rspList); } else { responseList = _responses[_reRoutedAddress]; if (!responseList.IsComplete) { responseList.AddResponse(response); } } } } } } }
public TextResponse(Response.Type type, string body) : base(type, body) { }
public ErrorResponse(Response.Type type, Exception body) : base(type, body) { }
protected Response(Response.Type type, T body) { this.ResponseType = type; this.Body = body; }
public ExtendedResponse(Response.Type type, Content content) : base(type, content) { }