public bool Read(byte[] buffer, ref int offset, ref int bytesTransferred) { while (bytesTransferred > 0) { switch (_receiveState) { case ExtensionFrameState.Flags: Flags = (FrameFlags) buffer[offset]; _receiveState = ExtensionFrameState.ExtensionId; ++offset; --bytesTransferred; break; case ExtensionFrameState.ExtensionId: var extensionId = buffer[offset]; ++offset; --bytesTransferred; _receiveState = ExtensionFrameState.Payload; _receiveFrame = (ExtensionFrame) _extensionFactory(extensionId); break; case ExtensionFrameState.Payload: var isCompleted = _receiveFrame.Read(buffer, ref offset, ref bytesTransferred); if (isCompleted) { _frameReceived(_receiveFrame); _receiveState = ExtensionFrameState.Flags; } return isCompleted; } } return false; }
private void OnExtensionFrame(ExtensionFrame frame) { if (frame.Payload is DotNetType) { _inboundDotNetType = ((DotNetType) frame.Payload).CreateType(); } if (frame.ExtensionId == _ackExtensionId) { var ackCount = _ackReceiver.Confirm((AckFrame) frame); if (_messageStore != null) { _messageStore.Remove(ackCount); var msgsToSend = new List<object>(); _messageStore.Peek(msgsToSend, _ackReceiver.FreeSlots); foreach (var o in msgsToSend) { //TODO: We should really send a list so that SendMore() can be sued _ackReceiver.Send((MessageFrame)o); } } if (AckReceived != null) AckReceived((AckFrame) frame); } }
private void OnExtension(ExtensionFrame obj) { ExtensionFrameReceived(obj); }
private void OnExtensionFrame(ExtensionFrame obj) { if (obj.Payload is DotNetType) { var type = (DotNetType) obj.Payload; _payloadDotNetType = type.CreateType(); } }