private void Handle(AcceptMessage m) { if (_isStopped) { return; } if (_initiator.CheckCreateChannel != null) { if (_initiator.CheckCreateChannel(m.Socket.RemoteEndPoint, m.Socket) == false) { m.Socket.Close(); return; } } if (_initiator.TokenRequired) { Context.ActorOf(Props.Create(() => new TokenChecker(_initiator, this, m.Socket))); } else { var channel = Context.ActorOf(Props.Create(() => new TcpChannel(_initiator, m.Socket, null))); if (channel == null) { _logger?.TraceFormat("Deny a connection. (EndPoint={0})", m.Socket.RemoteEndPoint); return; } _logger?.TraceFormat("Accept a connection. (EndPoint={0})", m.Socket.RemoteEndPoint); Context.Watch(channel); _channelSet.Add(channel); } }
private void Handle(AcceptMessage m) { if (_isStopped) { return; } if (_initiator.CheckCreateChannel != null) { if (_initiator.CheckCreateChannel(m.SenderEndPoint, m.SenderConnection) == false) { m.SenderConnection.Disconnect("Deny new connection"); return; } } IActorRef channel; if (_initiator.TokenRequired) { WaitingItem item; lock (_waitingMap) { if (_waitingMap.TryGetValue(m.Token, out item) == false) { m.SenderConnection.Disconnect("Token not found"); return; } _waitingMap.Remove(m.Token); } channel = Context.ActorOf(Props.Create(() => new UdpChannel(_initiator, m.SenderConnection, item.Tag, item.BindingActor))); } else { channel = Context.ActorOf(Props.Create(() => new UdpChannel(_initiator, m.SenderConnection, null, null))); } if (channel == null) { m.SenderConnection.Deny("Server Deny"); _logger?.ErrorFormat("Deny a connection. (EndPoint={0})", m.SenderEndPoint); return; } if (_channelMap.TryAdd(m.SenderConnection, channel) == false) { _logger?.ErrorFormat("Failed in adding new connection. (EndPoint={0})", m.SenderEndPoint); m.SenderConnection.Deny(); channel.Tell(PoisonPill.Instance); return; } _logger?.TraceFormat("Accept a connection. (EndPoint={0})", m.SenderEndPoint); Context.Watch(channel); _channelSet.Add(channel); }