예제 #1
0
파일: ComServer.cs 프로젝트: nakky/Snowball
        void OnConnectedInternal(TCPConnection connection)
        {
            if (connection == null)
            {
                return;
            }

            connection.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

            lock (this)
            {
                ComSnowballNode node = new ComSnowballNode(connection);

                if (nodeTcpMap.ContainsKey(node.TcpEndPoint))
                {
                    Disconnect(node);
                }
                else
                {
                    nodeTcpMap.Add(node.TcpEndPoint, node);

                    node.HealthLostCount = 0;

                    connection.OnDisconnected = OnDisconnectedInternal;
                    connection.OnPoll         = OnPoll;
                }

                //Util.Log("Server:Connected");
            }
        }
예제 #2
0
파일: ComClient.cs 프로젝트: nakky/Snowball
        void OnConnectedInternal(string ip, TCPConnection connection)
        {
            if (connection != null)
            {
                connection.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);

                lock (serverNodeLocker)
                {
                    serverNode = new ComSnowballNode(connection);
                }

                udpTerminal.ReceiveStart();

                connection.OnDisconnected = OnDisconnectedInternal;
                connection.OnPoll         = OnPoll;

                IssueIdData ldata = new IssueIdData();

                if (UserId != 0)
                {
                    if (previousServerNode != null && previousServerNode.AesEncrypter != null)
                    {
                        ldata.Id             = UserId;
                        ldata.encryptionData = previousServerNode.AesEncrypter.Encrypt(Global.ReconnectRawData);
                    }
                    else
                    {
                        UserId = 0;
                    }
                }

                if (UserId == 0)
                {
                    ldata.Id = UserId;
                }

                SendInternal((short)PreservedChannelId.IssueId, ldata);

                healthLostCount = 0;

                //Util.Log("Client:Connected");

                isConnecting = false;
            }
            else
            {
                isConnecting = false;
                OnConnectError(ip);
            }
        }