internal void Send(ProtocolChannel <TSender> protocolChannel, byte[] bytes) { if (!protocolChannel.Announced) { lock (this._protocols) if (!protocolChannel.Announced) { this.Reset(protocolChannel); } } this._channel.Send(ByteHelper.InsertByte(protocolChannel.Id, bytes)); }
private void RegisterProtocolInternal(string protocolName, Action <IMessageChannel <TSender> > callback) { if (string.IsNullOrEmpty(protocolName)) { throw new ArgumentNullException(nameof(protocolName)); } ProtocolChannel <TSender> proto; lock (this._protocols) { if (this._protocols.ContainsKey(protocolName)) { throw new InvalidOperationException("The given protocol is already registered!"); } var protocolId = this.GetFreeId(); proto = new ProtocolChannel <TSender>(this, protocolName, protocolId); this._protocols.Add(protocolName, proto); } callback(proto); this.Reset(proto); }
internal void RemoveSender(ProtocolChannel <TSender> protocolChannel, TSender sender) { this._byteProtocol.RemoveSender(sender, protocolChannel.Id); protocolChannel.OnRemovedSender(sender); }
internal void Reset(ProtocolChannel <TSender> protocolChannel) { protocolChannel.Announced = true; this._byteProtocol.SetProtocol(protocolChannel.Id, protocolChannel.Name); }