public void WriteGreeting(NodeGreetingMessage greetingMessage) { var messageFrame = new MessageFrame { RawMessage = greetingMessage.Serialize() }; _queueSocket.Write(messageFrame); }
public void Add(MessageFrame messageFrame) { if (messageFrame == null) { throw new ArgumentNullException("messageFrame"); } if (_singleMessageFrames.TryAdd(messageFrame)) { MessageCounterSignal.Increment(); MessageFrameAdded(messageFrame); } }
public async Task WriteMessageFrameAsync(MessageFrame messageFrame, CancellationToken cancellationToken) { if (messageFrame == null) { throw new ArgumentNullException("messageFrame"); } if (messageFrame.RawMessage == null) { throw new ArgumentException("messageFrame.RawMessage cannot be null"); } _queueSocket.Write(messageFrame); }
public void WriteMessageFrame(MessageFrame messageFrame) { if (messageFrame == null) { throw new ArgumentNullException("messageFrame"); } if (messageFrame.RawMessage == null) { throw new ArgumentException("messageFrame.RawMessage cannot be null"); } _queueSocket.Write(messageFrame); }
public async Task WriteMessageFrameAsync(MessageFrame messageFrame, CancellationToken cancellationToken) { if (messageFrame == null) { throw new ArgumentNullException("messageFrame"); } if (messageFrame.RawMessage == null) { throw new ArgumentException("messageFrame.RawMessage cannot be null"); } await CreateBufferWriteSingleAsync(messageFrame, cancellationToken); }
public void WriteMessageFrame(MessageFrame messageFrame) { if (messageFrame == null) { throw new ArgumentNullException("messageFrame"); } if (messageFrame.RawMessage == null) { throw new ArgumentException("messageFrame.RawMessage cannot be null"); } CreateBufferWriteSingle(messageFrame); }
public MessageFrame CreateFromMessage(IMessage message) { if (message == null) { throw new ArgumentNullException("message"); } var messageFrame = new MessageFrame { MessageTypeId = message.MessageTypeId, RawMessage = _messageSerialization.Serialize(message) }; return(messageFrame); }
private void SendMessageFrame(IMessageFrameWriter writer, MessageFrame messageFrame) { try { writer.WriteMessageFrame(messageFrame); } catch { if (_resentMessageFrames.TryAdd(messageFrame)) { Interlocked.Increment(ref _resentMessageFramesCount); } throw; } }
private async Task SendMessageFrameAsync(IMessageFrameWriter writer, MessageFrame messageFrame, CancellationToken cancellationToken) { try { await writer.WriteMessageFrameAsync(messageFrame, cancellationToken); } catch { if (_resentMessageFrames.TryAdd(messageFrame)) { Interlocked.Increment(ref _resentMessageFramesCount); } throw; } }
private void CreateBufferWriteSingle(MessageFrame messageFrame) { var sendBufferSize = MessageFrame.HeaderSize + messageFrame.RawMessage.Length; WeakReference <MemoryStream> reference; var mem = GetOrCreateMemoryStream(sendBufferSize, out reference); try { WriteTypeId(mem, messageFrame.MessageTypeId); WriteLength(mem, messageFrame.RawMessage.Length); WriteBody(mem, messageFrame.RawMessage); var toSend = mem.GetBuffer(); _streamSocket.Write(toSend, 0, sendBufferSize); } finally { mem.SetLength(0); RecycledMemoryStreams.Enqueue(reference); } }
private async Task CreateBufferWriteSingleAsync(MessageFrame messageFrame, CancellationToken cancellationToken) { var sendBufferSize = MessageFrame.HeaderSize + messageFrame.RawMessage.Length; WeakReference <MemoryStream> reference; var mem = GetOrCreateMemoryStream(sendBufferSize, out reference); try { WriteTypeId(mem, messageFrame.MessageTypeId); WriteLength(mem, messageFrame.RawMessage.Length); WriteBody(mem, messageFrame.RawMessage); var toSend = mem.GetBuffer(); await _streamSocket.WriteAsync(toSend, 0, sendBufferSize, cancellationToken); } finally { mem.SetLength(0); RecycledMemoryStreams.Enqueue(reference); } }
public void AddMessageFrame(MessageFrame messageFrame) { _messageQueue.Add(messageFrame); }