protected override void ParseChunk(Chunk chunk) { base.ParseChunk(chunk); if (_sendToken) { _sendToken = false; sendToken(); } }
public virtual void Update() { if (CanReceiveData()) { var data = ReceivedData(); var memory = new MemoryStream(data); var reader = new EndianBinaryReader(EndianBitConverter.Big, memory); while (memory.Position < memory.Length) { switch (CurrentState) { case ClientStates.Handshake_WaitForS0: { reader.ReadByte(); CurrentState = ClientStates.Handshake_WaitForS1; } break; case ClientStates.Handshake_WaitForS1: { var s1Chunk = reader.ReadBytes(Globals.Handshake_Length); SendData(Handshake.GenerateC2(s1Chunk)); CurrentState = ClientStates.Handshake_WaitForS2; } break; case ClientStates.Handshake_WaitForS2: { var s2Chunk = reader.ReadBytes(Globals.Handshake_Length); CurrentState = ClientStates.Handshake_Done; } break; case ClientStates.Handshake_Done: { var chunk = new Chunk(); chunk.Load(memory); ParseChunk(chunk); } break; } } } }
public void SendMessage(Chunk chunk) { SendData(chunk.ToBytes()); }
protected virtual void ParseChunk(Chunk chunk) { //TODO: Add automatic responses to window acknowledgements if (chunk.MHeader.MessageType == 5 || chunk.MHeader.MessageType == 3) //This are acknowledgements { var ack = new WindowAcknowledgement(-1); ack.ParseChunkData(chunk); SendMessage(new WindowAcknowledgement(ack.WindowSize)); } }
public void ParseChunkData(Chunk chunk) { var dataMemory = new MemoryStream(chunk.Data); ParseChunkData(dataMemory); }