public static Guid ResponseId(this BasicMessage message) { Guid result = default(Guid); if (message.Headers.ContainsKey(ResponseIdKey)) { Guid.TryParse(message.Headers[ResponseIdKey], out result); } return(result); }
public void SendMessage(BasicMessage message) { if (closed) throw new InvalidOperationException("Socket is closed"); using (var stream = protocol.ToStream(new BasicMessage[] { message })) { stream.Position = 0; while (stream.Position < stream.Length) { var remainingBytes = stream.Length - stream.Position; var bufferSize = (remainingBytes < maxBufferSize) ? (int)remainingBytes : maxBufferSize; var buffer = new byte[bufferSize]; stream.Read(buffer, 0, bufferSize); var sent = clientSocket.Send(buffer); if (sent != bufferSize) { log.WarnFormat("Sent less bytes({0}) than the buffer size({1}).", sent, bufferSize); var bytesToReturn = (stream.Position - bufferSize) + sent; stream.Position = bytesToReturn; } } } }
private void NextMessage(BasicMessage message) { foreach (var item in observers) { item.OnNext(message); } }
public static BasicMessage ResponseId(this BasicMessage message, Guid id) { message.Headers.Add(ResponseIdKey, id.ToString()); return(message); }
public static Guid Id(this BasicMessage message) { return(Guid.Parse(message.Headers[MessageIdKey])); }
public static BasicMessage Sender(this BasicMessage message, string clientName) { message.Headers.Add(SenderKey, clientName); return(message); }
public static string Sender(this BasicMessage message) { return(message.Headers[SenderKey]); }