private void ProcessExtended(IPeerWireClient client, int commandLength, byte[] payload) { Int32 msgId = payload[0]; byte[] buffer = payload.GetBytes(1, commandLength - 1); if (msgId == 0) { BDict extendedHandshake = (BDict)BencodingUtils.Decode(buffer); BDict mDict = (BDict)extendedHandshake["m"]; foreach (KeyValuePair <string, IBencodingType> pair in mDict) { BInt i = (BInt)pair.Value; this._extIncoming.Add(new ClientProtocolIDMap(client, pair.Key, (byte)i)); IBTExtension ext = this.FindIBTExtensionByProtocol(pair.Key); if (ext != null) { ext.OnHandshake(client, buffer); } } } else { string protocol = this.FindIBTProtocolByMessageID(msgId); IBTExtension ext = this.FindIBTExtensionByProtocol(protocol); if (ext != null) { ext.OnExtendedMessage(client, buffer); } } }
public byte GetOutgoingMessageID(IPeerWireClient client, IBTExtension extension) { ClientProtocolIDMap map = this._extOutgoing.Find(f => f.Client == client && f.Protocol == extension.Protocol); if (map != null) { return(map.CommandID); } return(0); }
public byte GetOutgoingMessageID(IPeerWireClient client, IBTExtension extension) { var map = _extOutgoing.Find(f => f.Client == client && f.Protocol == extension.Protocol); return(map?.CommandID ?? 0); }
public void UnregisterProtocolExtension(IPeerWireClient client, IBTExtension extension) { _protocolExtensions.Remove(extension); extension.Deinit(); }
public void RegisterProtocolExtension(IPeerWireClient client, IBTExtension extension) { _protocolExtensions.Add(extension); extension.Init(this); }
public byte GetOutgoingMessageID(IPeerWireClient client, IBTExtension extension) { ClientProtocolIDMap map = _extOutgoing.Find(f => f.Client == client && f.Protocol == extension.Protocol); if (map != null) { return map.CommandID; } return 0; }