예제 #1
0
        public void ExecuteExit(ChatPacket packet)
        {
            ChatRoomJoined roomJoined = BlindChatUtil.ChatPacketToStruct <ChatRoomJoined>(packet);

            if (roomJoined.UserID == _UserID)
            {
                string sql = $"delete from ChatRoomJoined where RoomID = {roomJoined.RoomID};";
                DB.ExecuteNonQuery(sql);
                sql = $"delete from ChatRoom where ID = {roomJoined.RoomID};";
                DB.ExecuteNonQuery(sql);

                roomList.RemoveAt(roomList.FindIndex(x => x.ID == roomJoined.RoomID));
            }
            else
            {
                string sql = $"delete from ChatRoomJoined where UserID = {roomJoined.UserID} and RoomID = {roomJoined.RoomID}";
                DB.ExecuteNonQuery(sql);

                //ChatMessage message = new ChatMessage();
                //message.RoomID = roomJoined.RoomID;
                //message.UserID = 0;
                //message.Time = roomJoined.Time;

                //User user = BlindChat.userList.Find(x => x.ID == roomJoined.UserID);
                //message.Message = $"{user.Name}님이 나갔습니다.";

                //AddMessage(message);
            }


            ExecuteWithInvoke(form, delegate
            {
                UI._RoomControl.LoadRooms();
            });
        }
예제 #2
0
        public ChatRoomJoined GetRoomJoined(SQLiteDataReader rdr)
        {
            ChatRoomJoined roomJoined = new ChatRoomJoined();

            roomJoined.ID     = int.Parse(rdr["ID"].ToString());
            roomJoined.UserID = uint.Parse(rdr["UserID"].ToString());
            roomJoined.RoomID = int.Parse(rdr["RoomID"].ToString());
            roomJoined.Time   = rdr["Time"].ToString();

            return(roomJoined);
        }
예제 #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));
        }
예제 #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();
            }
        }
예제 #5
0
        public void AddMember(ChatRoomJoined roomJoined)
        {
            string sql = $"insert into ChatRoomJoined (ID, roomID, userID, time) values ({roomJoined.ID}, {roomJoined.RoomID}, {roomJoined.UserID}, \'{roomJoined.Time}\');";

            DB.ExecuteNonQuery(sql);


            ExecuteWithInvoke(form, delegate
            {
                //수정
                //UI._RoomControl.LoadRooms();
                foreach (Room_Item item in UI._RoomControl.RoomItem_LayoutPanel.Controls)
                {
                    if (item.ID == roomJoined.RoomID)
                    {
                        item.UserCount = BlindChat.GetUserList(roomJoined.RoomID).Count().ToString() + "    |";
                        UI._RoomControl.RoomItem_LayoutPanel.Controls.SetChildIndex((Control)item, 0);
                        UI._RoomControl.RoomItem_LayoutPanel.Invalidate();
                    }
                }
            });
        }
예제 #6
0
 public static ChatPacket StructToChatPacket(ChatRoomJoined roomJoined, ChatType type = ChatType.RoomJoined)
 {
     byte[] data = BlindNetUtil.StructToByte(roomJoined);
     return(BlindChatUtil.ByteToChatPacket(data, type));
 }