public CourierNetworkContext Join(ReadableCourierEndpoint endpoint) { var context = new NetworkContextImpl(this); contexts.Add(context); return(context); }
public CourierNetworkContext Join(ReadableCourierEndpoint endpoint) { var context = new NetworkContextImpl(this, networkingProxy, configuration, endpoint); context.Initialize(); return(context); }
private void Broadcast(NetworkContextImpl senderContext, byte[] buffer, int offset, int length) { byte[] payload = new byte[length]; Buffer.BlockCopy(buffer, offset, payload, 0, length); if (StaticRandom.NextDouble() > Math.Sqrt(1 - dropRate)) { return; } foreach (var context in contexts) { if (StaticRandom.NextDouble() > Math.Sqrt(1 - dropRate)) { return; } if (context != senderContext) { context.HandleDataArrived(payload); } } }