public ProxyContact Construct(IPEndPoint iPEndPoint, Guid networkId, Identifier512 remoteId) { lock (proxies) { if (!proxies.ContainsKey(iPEndPoint)) { var proxy = new UdpProxy() { EndPoint = iPEndPoint }; var kvp = new KeyValuePair<ProxyContact, UdpProxy>(new ProxyContact(this.Type, proxy), proxy); proxies[iPEndPoint] = kvp; kvp.Key.NetworkId = networkId; kvp.Key.Identifier = remoteId; } return proxies[iPEndPoint].Key; } }
public Callback.WaitToken SendPing(ProxyContact source, UdpProxy destination, bool synchronous=true) { var t = callback.AllocateToken(); MemoryStream m = new MemoryStream(); Serializer.SerializeWithLengthPrefix<ProxyContact>(m, source, PrefixStyle.Base128); m.WriteByte(0); BinaryWriter writer = new BinaryWriter(m); writer.Write(t.Id); Send(m.ToArray(), destination.EndPoint, synchronous); return t; }