Пример #1
0
    // 방 목록 갱신
    private void InterpretRenewRoomList(Network.CPacket packet, int payloadSize)
    {
        Debug.Log("Renew Room");

        DeleteAllRoomToListView();
        rooms.Clear();

        int roomCount = payloadSize / 24;

        if (payloadSize % 24 != 0)
        {
            Debug.Log("Room Renew Error!");
        }

        Debug.LogFormat("Room Count : {0}", roomCount);

        for (int i = 0; i < roomCount; i++)
        {
            int    rid    = packet.ReadInt32();
            int    ucount = packet.ReadInt32();
            string hname  = packet.ReadString(16);

            Debug.Log("Room id = " + rid + " " + hname);

            rooms.Add(new Room(rid, ucount, hname));
        }

        RenewRoomListView();
    }
Пример #2
0
    // 방 들어가기
    private void InterpretJoinRoom(Network.CPacket packet, int payloadSize)
    {
        CClientInfo.ThisRoom = CClientInfo.JoinRoom.GetRoomInfo(joinRoomNumber, packet, payloadSize);

        _tcpManager.DeletePacketInterpret();
        SceneManager.LoadScene("Room");
    }
Пример #3
0
    // 패킷 해석
    private void PacketInterpret(byte[] data)
    {
        // 헤더 읽기
        Network.CPacket packet = new Network.CPacket(data);
        packet.ReadHeader(out byte payloadSize, out short messageType);
        Debug.LogFormat("Lobby Header : payloadSize = {0}, messageType = {1}", payloadSize, messageType);

        switch ((int)messageType)
        {
        case (int)MessageCode.RoomCreateAccept:
            InterpretCreateRoom(packet);
            break;

        case (int)MessageCode.RoomJoinAccept:
            InterpretJoinRoom(packet, (int)payloadSize);
            break;

        case (int)MessageCode.RoomListAccept:
            InterpretRenewRoomList(packet, (int)payloadSize);
            break;

        case (int)MessageCode.RoomCountAccept:
            ErrorHandling("아이디 혹은 비밀번호가 일치하지 않습니다.");
            break;

        case (int)MessageCode.RoomJoinFail:
            ErrorHandling("방 접속에 실패했습니다");
            break;

        default:
            ErrorHandling("오류가 발생했습니다. 개발자에게 문의하세요.");
            break;
        }
    }
Пример #4
0
    private void PacketInterpret(byte[] data)
    {
        // 헤더 읽기
        Network.CPacket packet = new Network.CPacket(data);
        packet.ReadHeader(out byte payloadSize, out short messageType);
        Debug.LogFormat("Header : payloadSize = {0}, messageType = {1}", payloadSize, messageType);

        switch ((int)messageType)
        {
        case (int)MessageCode.LoginSuccess:
            InterpretLoginSuccess(packet);
            break;

        case (int)MessageCode.RegisterSuccess:
            //InterpretRegisterSuccess(packet);
            ErrorHandling("회원가입 완료");
            break;

        case (int)MessageCode.LobbySuccess:
            InterpretLobbySuccess(packet);
            break;

        case (int)MessageCode.RegisterFail:
            ErrorHandling("이미 가입된 아이디 입니다!");
            break;

        case (int)MessageCode.LoginFail:
            ErrorHandling("아이디 혹은 비밀번호가 일치하지 않습니다.");
            break;

        default:
            ErrorHandling("오류가 발생했습니다. 개발자에게 문의하세요.");
            break;
        }
    }
Пример #5
0
    private void PacketInterpret(byte[] data)
    {
        // 헤더 읽기
        Network.CPacket packet = new Network.CPacket(data);
        packet.ReadHeader(out byte payloadSize, out short messageType);
        Debug.LogFormat("ReadyRoom Header : payloadSize = {0}, messageType = {1}", payloadSize, messageType);

        switch ((int)messageType)
        {
        case (int)MessageCode.GameStartAccept:
            GameStart(packet.ReadInt32());
            break;

        case (int)MessageCode.GuestQuitRoom:
            QuitRoom();
            break;

        case (int)MessageCode.HostQuitRoom:
            QuitRoom();
            break;

        case (int)MessageCode.NoticeUserQuit:
            DeleteQuitUser(packet);
            break;

        case (int)MessageCode.NewGuest:
            InterpretAddGuest(packet);
            break;

        default:
            Debug.Log("오류가 발생했습니다. 개발자에게 문의하세요.");
            break;
        }
    }
Пример #6
0
        // 방 정보를 얻음
        public static JoinRoom GetRoomInfo(int rid, Network.CPacket packet, int payloadSize)
        {
            int myslot = packet.ReadInt32();
            int ucnt   = packet.ReadInt32();

            Debug.LogFormat("ucnt : ", ucnt);
            List <User> others = new List <User>();

            int[] slots = new int[4];
            int   slot;

            int userCount = payloadSize / 24;

            for (int i = 0; i < userCount; i++)
            {
                string id = packet.ReadString(16);
                slot = packet.ReadInt32();
                int clear = packet.ReadInt32();
                others.Add(new User(id, clear, slot));
                Debug.Log("CClientInfo - JoinRoom : A Slot is " + slot + " and id " + id);
            }

            ThisUser.Slot = myslot;

            return(new JoinRoom(rid, slots, others, false));
        }
Пример #7
0
    // 인원이 추가된 경우
    private void InterpretAddGuest(Network.CPacket packet)
    {
        string id    = packet.ReadString(16);
        int    slot  = packet.ReadInt32();
        int    clear = packet.ReadInt32();

        AddGuest(id, slot, clear);
    }
Пример #8
0
    // 인원이 빠져나감 알림
    private void DeleteQuitUser(Network.CPacket packet)
    {
        int slotNum = packet.ReadInt32();

        CClientInfo.JoinRoom.DeleteUser(slotNum);

        Debug.Log($"Delete User {slotNum}");

        UpdateRoomListView();
    }
Пример #9
0
    private void InterpretRegisterSuccess(Network.CPacket packet)
    {
        int    uid   = packet.ReadInt32();
        string id    = packet.ReadString(16);
        int    clear = packet.ReadInt32();

        CClientInfo.ThisUser = new CClientInfo.User(uid, id, clear);

        var message = Network.CPacketFactory.CreateLobbyRequest();

        _tcpManager.Send(message.data);
    }
Пример #10
0
    // 내 방을 만들기
    private void InterpretCreateRoom(Network.CPacket packet)
    {
        Debug.Log("room Create");
        int rid = packet.ReadInt32();

        CClientInfo.ThisRoom = new CClientInfo.JoinRoom(rid, new int[4] {
            0, -1, -1, -1
        }, new List <CClientInfo.User>(), true);
        CClientInfo.ThisUser.Slot = 0;

        _tcpManager.DeletePacketInterpret();
        SceneManager.LoadScene("Room");
    }
Пример #11
0
 private void InterpretLobbySuccess(Network.CPacket packet)
 {
     _tcpManager.DeletePacketInterpret();
     SceneManager.LoadScene("Lobby");
 }