예제 #1
0
 public void ProcessMsg(ushort _type)
 {
     if (m_player != null)
     {
         m_player.ProcessMsg(_type, m_serverSession.In);
     }
 }
예제 #2
0
        void ProcessMsg(ushort _type)
        {
            MsgType type = (MsgType)_type;

            if (type < MsgType.GameMsg)
            {
                switch (type)
                {
                case MsgType.Login:
                {
                    m_name     = System.Text.Encoding.Default.GetString(In.ReadBytes(16));
                    m_name     = m_name.Substring(0, m_name.IndexOf(char.MinValue));
                    m_password = System.Text.Encoding.Default.GetString(In.ReadBytes(16));
                    m_password = m_password.Substring(0, m_password.IndexOf(char.MinValue));
                    m_state    = State.Login;

                    Out.Write((ushort)MsgType.Login);
                    Out.Write((ushort)0);

                    Console.WriteLine("{0} login. (pw:{1})", m_name, m_password);
                }
                break;

                case MsgType.Logout:
                {
                    switch (m_state)
                    {
                    case State.Matching:
                        m_core.RemoveFromMatchingList(this);
                        break;

                    case State.InGame:
                        m_game.OnPlayerLogout(m_player);
                        break;

                    default:
                        break;
                    }
                    m_game   = null;
                    m_player = null;
                    m_state  = State.Logout;

                    Console.WriteLine("{0} logout.", m_name);
                }
                break;

                case MsgType.Practice:
                {
                    m_core.Practice(this);
                }
                break;

                case MsgType.Matching:
                {
                    if (m_state == State.Login)
                    {
                        m_state = State.Matching;
                        m_core.AddToMatchingList(this);

                        Out.Write((ushort)MsgType.Matching);
                        Out.Write((ushort)0);

                        Console.WriteLine("{0} is matching.", m_name);
                    }
                }
                break;

                case MsgType.CancelMatching:
                {
                    if (m_state == State.Matching)
                    {
                        m_state = State.Login;
                        m_core.RemoveFromMatchingList(this);

                        Out.Write((ushort)MsgType.CancelMatching);
                        Out.Write((ushort)0);

                        Console.WriteLine("{0} is cancel maching.", m_name);
                    }
                }
                break;

                default:
                {
                    Console.WriteLine("error msg type {0}.", type.ToString());
                }
                break;
                }
            }
            else
            {
                if (m_player != null)
                {
                    m_player.ProcessMsg(_type, In);
                }
            }
        }