コード例 #1
0
        private TClient InternalTcpClientConnected(TcpClient acceptedTcpClient)
        {
            var endPoint = ((IPEndPoint)acceptedTcpClient.Client.RemoteEndPoint);
            var id       = GuidUtils.CreateUniqueId(endPoint.Address);

            var denyReason = OnClientAcceptanceQuestioned(id, endPoint, acceptedTcpClient);

            if (denyReason != ServerAcceptanceMessage.ReasonOk)
            {
                acceptedTcpClient.Client.Send(ServerAcceptanceMessage.Deny(id, denyReason).ToBytes());
                return(null);
            }

            acceptedTcpClient.Client.Send(ServerAcceptanceMessage.Approve(id).ToBytes());
            var client = CreateClient(id, endPoint, acceptedTcpClient);

            OnClientConnected(client);
            return(client);
        }