private void InitializeProtocolStackLayers() { // Create the contexts: ProtocolContext lastContext = null; for (int i = 0; i < this.EndPoint.ProtocolList.Count; i++) { Protocol protocol = this.EndPoint.ProtocolList[i]; ProtocolContext context = new ProtocolContext(protocol); context.LowerProtocol = lastContext; context.PhysicalConnection = this; if (lastContext == null) { this.LowestProtocolContext = context; } else { lastContext.UpperProtocol = context; } lastContext = context; } this.HighestProtocolContext = lastContext; this.LowestProtocolContext.AdvanceNegociation(); }
public void SendProtocolBytes(Buffer bytes, ProtocolContext protocol) { if (protocol.LowerProtocol == null) { this.SendBuffer(bytes); } else { Buffer encodedBytes; var result = protocol.Encode(bytes, out encodedBytes); if (result != EncodeResult.Success) { return; } this.SendBuffer(encodedBytes); } }