Exemple #1
0
        public void RequestChat(ServerPacketData packetData)
        {
            var sessionID    = packetData.SessionID;
            var sessionIndex = packetData.SessionIndex;

            MainServer.MainLogger.Debug("Room RequestChat");

            try
            {
                var roomObject = CheckRoomAndRoomUser(sessionIndex);

                if (roomObject.Item1 == false)
                {
                    return;
                }
                var reqData      = MessagePackSerializer.Deserialize <PKTReqRoomChat>(packetData.BodyData);
                var notifyPacket = new PKTNtfRoomChat()
                {
                    UserID      = roomObject.Item3.UserID,
                    ChatMessage = reqData.ChatMessage
                };

                var Body     = MessagePackSerializer.Serialize(notifyPacket);
                var sendData = PacketToBytes.Make(PACKETID.NTF_ROOM_CHAT, Body);
                roomObject.Item2.Broadcast(-1, sendData);
                MainServer.MainLogger.Debug("Room RequestChat - Success");
            }
            catch (Exception e)
            {
                MainServer.MainLogger.Error(e.ToString());
            }
        }
Exemple #2
0
        public void NofifyPacketNewUser(string newUserNetSessionID, string newUserID)
        {
            var packet = new PKTNtfRoomNewUser();

            packet.UserID = newUserID;

            var bodyData   = MessagePackSerializer.Serialize(packet);
            var sendPacket = PacketToBytes.Make(PACKETID.NTF_ROOM_NEW_USER, bodyData);

            Broadcast(newUserNetSessionID, sendPacket);
        }
Exemple #3
0
        public void ResponseLoginToClient(ERROR_CODE errorCode, string sessionID)
        {
            var resLogin = new PKTResLogin()
            {
                Result = (short)errorCode
            };

            var bodyData = MessagePackSerializer.Serialize(resLogin);
            var sendData = PacketToBytes.Make(PACKETID.RES_LOGIN, bodyData);

            ServerNetwork.SendData(sessionID, sendData);
        }
Exemple #4
0
        public void NotifyMustCloseToClient(ERROR_CODE errorCode, string sessionID)
        {
            var resLogin = new PKNtfMustClose()
            {
                Result = (short)errorCode
            };

            var bodyData = MessagePackSerializer.Serialize(resLogin);
            var sendData = PacketToBytes.Make(PACKETID.NTF_MUST_CLOSE, bodyData);

            ServerNetwork.SendData(sessionID, sendData);
        }
Exemple #5
0
        void ResponseEnterRoomToClient(ERROR_CODE errorCode, string sessionID)
        {
            var resRoomEnter = new PKTResRoomEnter()
            {
                Result = (short)errorCode
            };

            var bodyData = MessagePackSerializer.Serialize(resRoomEnter);
            var sendData = PacketToBytes.Make(PACKETID.RES_ROOM_ENTER, bodyData);

            ServerNetwork.SendData(sessionID, sendData);
        }
Exemple #6
0
        public void NotifyPacketUserList(string userNetSessionID)
        {
            var packet = new CSBaseLib.PKTNtfRoomUserList();

            foreach (var user in UserList)
            {
                packet.UserIDList.Add(user.UserID);
            }

            var bodyData   = MessagePackSerializer.Serialize(packet);
            var sendPacket = PacketToBytes.Make(PACKETID.NTF_ROOM_USER_LIST, bodyData);

            NetSendFunc(userNetSessionID, sendPacket);
        }
Exemple #7
0
        public void NotifyPacketLeaveUser(string userID)
        {
            if (CurrentUserCount() == 0)
            {
                return;
            }

            var packet = new PKTNtfRoomLeaveUser();

            packet.UserID = userID;
            var bodyData   = MessagePackSerializer.Serialize(packet);
            var sendPacket = PacketToBytes.Make(PACKETID.NTF_ROOM_LEAVE_USER, bodyData);

            Broadcast(-1, sendPacket);
        }
        static public async Task <(bool Ret, string ErrStr)> RoomLeaveAsync(Dummy dummy)
        {
            var temp = new RoomLeaveReqJsonPacket();

            var sendData  = PacketToBytes.Make(PACKETID.REQ_ROOM_LEAVE, temp);
            var sendError = dummy.SendPacket(sendData.Length, sendData);

            if (sendError != "")
            {
                return(false, $"[RoomLeave - Request] {sendError}");
            }


            var(ret, errorStr, packetList) = await ReceivePacketAndCheck <RoomLeaveResJsonPacket>(
                dummy, 2, 4, PACKETID.RES_ROOM_LEAVE);

            return(ret, $"[RoomLeave - Res] {errorStr}");
        }
        static public async Task <(bool Ret, string ErrStr)> RoomEnterAsync(Dummy dummy, int roomNumber)
        {
            var reqPacket = new RoomEnterReqJsonPacket();

            reqPacket.RoomNum = roomNumber;

            var sendData  = PacketToBytes.Make(PACKETID.REQ_ROOM_ENTER, reqPacket);
            var sendError = dummy.SendPacket(sendData.Length, sendData);

            if (sendError != "")
            {
                return(false, $"[RoomEnter - Request] {sendError}");
            }

            var(ret, errorStr, packetList) = await ReceivePacketAndCheck <RoomEnterResJsonPacket>(
                dummy, 2, 4, PACKETID.RES_ROOM_ENTER);

            return(ret, $"[RoomEnter - Res] {errorStr}");
        }
        static public async Task <(bool Ret, string ErrStr)> LoginAsync(Dummy dummy)
        {
            var packet = new LoginReqJsonPacket()
            {
                UserID = dummy.GetUserID(),
                UserPW = "abcde",
            };

            var sendData  = PacketToBytes.Make(PACKETID.REQ_LOGIN, packet);
            var sendError = dummy.SendPacket(sendData.Length, sendData);

            if (sendError != "")
            {
                return(false, sendError);
            }

            var(ret, errorStr, packetList) = await ReceivePacketAndCheck <LoginResJsonPacket>(
                dummy, 2, 1, PACKETID.RES_LOGIN);

            return(ret, $"[Login - Res] {errorStr}");
        }
        static public async Task <(bool Ret, string ErrStr)> RoomChatAsync(Dummy dummy)
        {
            var ChatMessage = "dsdsd"; //TODO 랜덤한 문자로 바꾸기
            var packet      = new RoomChatReqJsoPacket()
            {
                Msg = ChatMessage,
            };

            var sendData  = PacketToBytes.Make(PACKETID.REQ_ROOM_CHAT, packet);
            var sendError = dummy.SendPacket(sendData.Length, sendData);

            if (sendError != "")
            {
                return(false, $"[RoomChat - Req] {sendError}");
            }

            var(ret, errorStr, packetList) = await ReceivePacketAndCheck <RoomChatResJsoPacket>(
                dummy, 2, 4, PACKETID.RES_ROOM_CHAT);

            return(ret, $"[RoomChat - Res] {errorStr}");
        }