Пример #1
0
        public void Migrate(string ip, int port, ServerType type)
        {
            if (type == ServerType.Login || type == ServerType.Town)
            {
                TCPsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                TCPsocket.Connect(ip, port);
                session = new Session(TCPsocket);
                TcpPort = port;
            }
            else if (type == ServerType.Field)
            {
                TCPsocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                TCPsocket.Connect(ip, port);
                session = new Session(TCPsocket);
                TcpPort = port;
            }

            Ip = ip;

            if (m_context != null)
            {
                m_context.Disconnect();
            }

            switch (type)
            {
            case ServerType.Login:
                m_context = new LoginContext(this, session);
                break;

            case ServerType.Town:
                m_context = new TownContext(this, session);
                break;

            case ServerType.Field:
                m_context = new FieldContext(this, session);
                break;
            }
        }