Example #1
0
        internal void Login(UserType typeCode, string UserID, string pwd, LocaleCode localeCode)
        {
            LoginPacket packet = new LoginPacket();
            packet.m_typeCode           = (byte)typeCode;
            packet.m_userID             = UserID;
            packet.m_userPwd            = pwd;
            packet.m_localeCode         = (byte)localeCode;
            packet.m_isAlreadyLogined   = 0;

            lock (m_lockSocket)
            {
                if (m_retryLoginPacket != null)
                    m_retryLoginPacket.Dispose();

                m_serverId = 0;
                m_retryLoginPacket = (LoginPacket)packet.Clone();
            }

            m_isLoginPacketSync = false;
            PushPacketInQueue(packet);
        }
Example #2
0
        internal void Logout()
        {
            lock (m_lockSocket)
            {
                LogoutPacket packet = new LogoutPacket();

                if (m_socket != null)
                {
                    m_socket.SendPacket(packet);
                }

                packet.Dispose();

                if (m_retryLoginPacket != null)
                {
                    m_retryLoginPacket.Dispose();
                    m_retryLoginPacket = null;
                }

                m_socketState = SocketState.Disconnected;
            }

            lock (m_retryPackets)
            {
                foreach (RetryPacket rp in m_retryPackets)
                {
                    rp.m_packet.Dispose();
                }
                m_retryPackets.Clear();
            }

            CallNotifyHandler(NotifyEventCode.Logout, 0, null, null);
        }
Example #3
0
        private void CleanupResource()
        {
            lock (m_retryPackets)
            {
                foreach (RetryPacket rp in m_retryPackets)
                {
                    rp.m_event.Set();
                    rp.m_packet.Dispose();
                }
                m_retryPackets.Clear();
            }

            lock (m_sendingPackets)
            {
                foreach (RetryPacket rp in m_sendingPackets)
                {
                    rp.m_packet.Dispose();
                }
                m_sendingPackets.Clear();
            }

            lock (m_lockSocket)
            {
                m_socketState = SocketState.Disconnected;

                if (m_retryLoginPacket != null)
                {
                    m_retryLoginPacket.Dispose();
                    m_retryLoginPacket = null;
                }

                if (m_socket != null)
                {
                    CloseSocket();
                }
            }
        }