Ejemplo n.º 1
0
        public void ChatMessageSend(string text, uint userID, int roomID)
        {
            ChatMessage message = new ChatMessage();

            message.Message = text;
            message.UserID  = userID;
            message.RoomID  = roomID;

            ChatPacketSend(BlindChatUtil.StructToChatPacket(message));
        }
Ejemplo n.º 2
0
        public void CreateRoom(string text, uint[] users)
        {
            //한 방에는 최대 20명
            NewRoomStruct newRoom = new NewRoomStruct();

            newRoom.Name   = text;
            newRoom.UserID = users;

            ChatPacketSend(BlindChatUtil.StructToChatPacket(newRoom));
        }
Ejemplo n.º 3
0
        public static void InviteUser(uint userID, int roomID)
        {
            ChatRoomJoined roomJoined = new ChatRoomJoined();

            roomJoined.UserID = userID;
            roomJoined.RoomID = roomID;

            ChatPacketSend(BlindChatUtil.StructToChatPacket(roomJoined));

            //Invitation inv = new Invitation();
            //inv.Name = roomName;
            //inv.RoomID = roomID;
            //inv.UserID = userID;

            //ChatPacketSend(BlindChatUtil.StructToChatPacket(inv));
        }
Ejemplo n.º 4
0
        public static void ExitRoom(uint userID, int roomID)
        {
            ChatRoomJoined roomJoined = new ChatRoomJoined();

            roomJoined.UserID = userID;
            roomJoined.RoomID = roomID;
            roomJoined.Time   = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

            ChatPacketSend(BlindChatUtil.StructToChatPacket(roomJoined, ChatType.Exit));

            Form form = BlindChatUtil.GetFormWithName(roomJoined.RoomID.ToString());

            if (form != null)
            {
                form.Close();
            }
        }
Ejemplo n.º 5
0
        public void Run()
        {
            ChatPacket    packet;
            ChatTimeStamp syncTime;

            User           user;
            ChatRoom       room;
            ChatRoomJoined roomJoined;
            ChatMessage    message;

            DB.Open();

            sendSock = new BlindSocket();
            sendSock.ConnectWithECDH(BlindNetConst.ServerIP, BlindNetConst.CHATPORT);

            recvSock = new BlindSocket();
            recvSock.ConnectWithECDH(BlindNetConst.ServerIP, BlindNetConst.CHATPORT + 1);


            syncTime = DB.GetAllTime();
            packet   = BlindChatUtil.StructToChatPacket(syncTime);
            ChatPacketSend(packet);


            //string sql;
            while (true)
            {
                packet = ChatPacketReceive();

                if (packet.Type == ChatType.User)
                {
                    //사용자 UI에 표시
                    user = BlindChatUtil.ChatPacketToStruct <User>(packet);
                    AddUser(user);
                }
                else if (packet.Type == ChatType.Room)
                {
                    //방추가 UI에 표시
                    room = BlindChatUtil.ChatPacketToStruct <ChatRoom>(packet);
                    AddRoom(room);
                }
                else if (packet.Type == ChatType.RoomJoined)
                {
                    //방인원 UI에 표시
                    roomJoined = BlindChatUtil.ChatPacketToStruct <ChatRoomJoined>(packet);
                    AddMember(roomJoined);
                }
                else if (packet.Type == ChatType.Message)
                {
                    //메시지 UI에 표시
                    message = BlindChatUtil.ChatPacketToStruct <ChatMessage>(packet);
                    AddMessage(message);
                }
                else if (packet.Type == ChatType.Reset)
                {
                    if (!Start)
                    {
                        LoadList();
                        LoadUI();
#if DEBUG
                        MessageBox.Show("데이터 로드 완료");
#endif
                    }
                    Start = true;
                }
                else if (packet.Type == ChatType.Exit)
                {
                    ExecuteExit(packet);
                }
                else
                {
                }
            }
        }