Beispiel #1
0
    public void ProcessMessage(BinaryMessage t_recvdMsg)
    {
        GameMessageReader t_reader = new GameMessageReader();
        t_reader.InitAdapter(ref t_recvdMsg);

        switch(t_reader.GetFunctionCode())
        {
            case (ushort)Function_Codes.FUNCTION_USER_NEWROOM:
                {
                    string t_name = "";
                    ushort t_roomType = 0;
                    t_reader.Decode_FunctionUserNewRoom(ref t_roomType,
                                                         ref t_name);

                    if(t_roomType == (ushort)Function_Codes.ROOM_TYPE_CHAT)
                    {
                        Debug.Log("NEW ROOM CHAT!");
                        Room t_room = new Room();
                        t_room.SetRoomInfo(ref t_name, ref t_roomType);
                        m_controller.m_liveController.SendRoomStateData(t_room);
                        if(!m_controller.m_liveController.CheckDataSaved())
                        {

                            m_controller.m_liveController.SendClientUserData(m_clientUser);
                        }
                        Application.LoadLevel(0);
                    }
                    break;
                }
        }
    }
    public void ProcessMessage(BinaryMessage t_recvdMsg)
    {
        GameMessageReader t_reader = new GameMessageReader();
        t_reader.InitAdapter(ref t_recvdMsg);
        Debug.Log(t_reader.GetFunctionCode().ToString() + " tank movement recd\n");
        switch( t_reader.GetFunctionCode ())
        {

            case (ushort)Function_Codes.FUNCTION_TANKROOM_USER_MOVE_TANK:
                {
                    float x = 0;
                    float y = 0;
                    float z = 0;
                    float h = 0;
                    float p = 0;
                    float r = 0;
                    t_reader.Decode_FunctionTankUpdatePOSHPR(ref x ,
                                                           ref y ,
                                                           ref z ,
                                                           ref h ,
                                                           ref p ,
                                                           ref r );
                    transform.position = new Vector3(x, y, z);
                    print(h.ToString() + p.ToString() + r.ToString());
                    Quaternion newOrientation = Quaternion.Euler(new Vector3(h,p,r));
                    transform.rotation = newOrientation;
                    break;
                }
            //case (ushort)Function_Codes.FUNCTION_TANKROOM_USER_ROTATE_TANK:
            //    {
            //        short direction = 0;
            //        t_reader.Decode_FunctionTankUpdateRotation(ref direction);

            //        if(direction == 1 )
            //        {
            //            transform.RotateAroundLocal(Vector3.up, -.02F);
            //        }
            //        if(direction == -1)
            //        {
            //            transform.RotateAroundLocal(Vector3.up, .02F);
            //        }

            //        break;
            //    }
        }
    }
Beispiel #3
0
    //End message specific process functions-----------------------------------
    public void ProcessMessage(BinaryMessage t_recvdMsg)
    {
        GameMessageReader msgReader = new GameMessageReader();
        msgReader.InitAdapter(ref t_recvdMsg);
        print("FunctionCode " + msgReader.GetFunctionCode());
        switch (msgReader.GetFunctionCode())
        {

            case (ushort)Function_Codes.FUNCTION_USER_LOGIN_RESP:
                {
                    int return_code = 0;
                    msgReader.Decode_FunctionUserLoginResp(ref return_code,
                                                               ref ClientUser.m_id,
                                                               ref ClientUser.m_username);
                    m_currentRoom.AddUserToWindow(ref ClientUser.m_username);
                    break;
                }
            case (ushort)Function_Codes.FUNCTION_USER_NEWROOM:
                {
                    ProcessFunctionUserNewRoom(ref msgReader);
                    break;
                }
            case (ushort)Function_Codes.FUNCTION_USER_IN_ROOM:
                {
                    ProcessClientUserInRoom(ref msgReader);
                    break;
                }
            case (ushort)Function_Codes.FUNCTION_USER_OUT_ROOM:
                {
                    ProcessUserOutRoom(ref msgReader);
                    break;
                }
            case (ushort)Function_Codes.FUNCTION_USER_CHAT:
                {
                    ProcessClientChatMsg(ref msgReader);
                    break;
                }
        }
    }
Beispiel #4
0
    bool ProcessUserOutRoom(ref GameMessageReader inMsgReader)
    {
        ulong t_userID = 0;
        User  t_user   = new User();
        inMsgReader.Decode_FunctionUserOutRoom(ref t_userID);
        print(t_userID);
        m_currentRoom.FindUserByID(t_userID , ref t_user );

        m_currentRoom.RemoveUserFromWindow(ref t_user.m_username);

        m_currentRoom.AddMessageToChatWindow(t_user.m_username +
                                              ": has left the channel");
        return true;
    }
Beispiel #5
0
    //---------------------------------------------------------------------
    //Client message specific process functions
    bool ProcessFunctionUserNewRoom( ref GameMessageReader inMsgReader)
    {
        string t_roomName = "";
        UInt16 t_roomType = 0;

            inMsgReader.Decode_FunctionUserNewRoom(ref t_roomType,
                                                    ref t_roomName);

            m_currentRoom.SetRoomInfo(ref t_roomName, ref t_roomType);

            if (t_roomType == (ushort)Function_Codes.ROOM_TYPE_TANKS)
            {
                Debug.Log("NEW ROOM TANKS!");
                m_controller.m_liveController.SendClientUserData(ClientUser);
                Room t_room = new Room();
                t_room.SetRoomInfo(ref t_roomName, ref t_roomType);
                m_controller.m_liveController.SendRoomStateData(t_room);
                m_controller.m_liveController.RemoveAllIntrest(this);
                Application.LoadLevel(1);
            }

        return true;
    }
Beispiel #6
0
    bool ProcessClientUserInRoom(ref GameMessageReader inMsgReader)
    {
        //print("FUNCTION_USER_IN_ROOM");
        List<User> t_list = new List<User>();
        ushort listSize = 0;
        inMsgReader.Decode_FunctionUserInRoom(ref t_list, ref listSize);

        if (listSize == 1 && t_list[0].m_id != ClientUser.m_id)
        {
            m_currentRoom.AddMessageToChatWindow (t_list[0].m_username +
                                                  " has joined the channel");
            m_currentRoom.AddUserToWindow(ref t_list[0].m_username);
            m_currentRoom.CopyList(ref t_list);
        }
        else if (listSize == 0)
        {
            return false;
        }
        else
        {
            m_currentRoom.CopyList(ref t_list);
            foreach( User t_user in t_list)
            {
                m_currentRoom.AddUserToWindow(ref t_user.m_username);
            }
        }

        return true;
    }
Beispiel #7
0
    bool ProcessClientChatMsg( ref GameMessageReader inMsgReader )
    {
        string userName = "";
        string chatMsg = "";
        UInt64 userID = 0;
        inMsgReader.Decode_FunctionUserChat(ref chatMsg , ref userName ,
                                            ref userID);

        m_currentRoom.AddMessageToChatWindow(userName + ": " + chatMsg);
        return true;
    }
Beispiel #8
0
    //Function: PumpRPCQueue()
    //Argument: none
    //Purpose: Function checks the socket for a buffered message. If yes then
    //         check the code of the message through the current function
    //         codes and then send the message off to the Intrested Objects
    //         of that function code.
    private void PumpRPCQueue()
    {
        BinaryMessage t_msg = new BinaryMessage();
           t_msg.Init();
           int pumped = m_reader.PumpMessageReader(ref m_sock, ref t_msg);
           if (pumped == 1)
           {
           GameMessageReader t_readerAdapter = new GameMessageReader();
           t_readerAdapter.InitAdapter(ref t_msg);

           List<IntrestedObj> t_list;
           if (m_funcCodeIntrestList.TryGetValue(t_readerAdapter.GetFunctionCode(),
                                                out t_list))
           {
               t_readerAdapter.ResetToFuncCode();
               foreach (IntrestedObj t_obj in t_list)
               {
                   t_obj.ProcessMessage(t_msg);
               }
           }

           }
    }