示例#1
0
        private void play_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (selectMusic > 0)
            {
                if (playState == true)
                {
                    playState           = false;
                    musicStop.IsEnabled = true;
                    musicStop.Opacity   = 1;
                    BitmapImage musicBit = new BitmapImage();
                    musicBit.BeginInit();
                    musicBit.UriSource = new Uri("image/pause.png", UriKind.RelativeOrAbsolute);
                    musicBit.EndInit();
                    play.Source = musicBit;

                    if (selectMusic < musicList.Count)
                    {
                        musicNext.Opacity      = 1;
                        musicNext.IsEnabled    = true;
                        musicPreNext.Opacity   = 1;
                        musicPreNext.IsEnabled = true;
                    }
                    musicStop.IsEnabled = true;
                    musicStop.Opacity   = 1;

                    mediaPlayerMain.Source = new Uri(musicList[selectMusic - 1], UriKind.RelativeOrAbsolute);
                    mediaPlayerMain.Play();
                    mediaPlayerMain.Volume = (double)sliderVolume.Value;

                    musiceStateInfo            = new MusiceStateInfo();
                    musiceStateInfo.MusiceName = lstMediaItems.SelectedItem.ToString();
                    musiceStateInfo.M_Kind     = (int)MusiceKind.Play;
                    Window1._ClientEngine.Send(NotifyType.Request_MusiceStateInfo, musiceStateInfo);
                }
                else
                {
                    playState           = true;
                    musicStop.IsEnabled = false;
                    musicStop.Opacity   = 0.5;

                    BitmapImage musicBit2 = new BitmapImage();
                    musicBit2.BeginInit();
                    musicBit2.UriSource = new Uri("image/play.png", UriKind.RelativeOrAbsolute);
                    musicBit2.EndInit();
                    play.Source = musicBit2;

                    mediaPlayerMain.Pause();

                    musiceStateInfo.MusiceName = lstMediaItems.SelectedItem.ToString();
                    musiceStateInfo.M_Kind     = (int)MusiceKind.Pause;
                    Window1._ClientEngine.Send(NotifyType.Request_MusiceStateInfo, musiceStateInfo);
                }
            }
        }
示例#2
0
        private void Element_MediaEnded(object sender, EventArgs e)
        {
            mediaPlayerMain.Stop();

            ++selectMusic;

            if (selectMusic > musicList.Count)
            {
                selectMusic = 1;
            }


            lstMediaItems.SelectedIndex = selectMusic - 1;

            mediaPlayerMain.Source = new Uri(musicList[selectMusic - 1], UriKind.RelativeOrAbsolute);
            mediaPlayerMain.Play();

            musiceStateInfo            = new MusiceStateInfo();
            musiceStateInfo.MusiceName = lstMediaItems.SelectedItem.ToString();
            musiceStateInfo.M_Kind     = (int)MusiceKind.Play;
            Window1._ClientEngine.Send(NotifyType.Request_MusiceStateInfo, musiceStateInfo);
        }
示例#3
0
        public void NotifyOccured(NotifyType notifyType, Socket socket, BaseInfo baseInfo)
        {
            Database database = Database.GetInstance();
            Server   server   = Server.GetInstance();
            Users    users    = Users.GetInstance();

            ResultInfo resultInfo = new ResultInfo();

            switch (notifyType)
            {
            case NotifyType.Request_EnterMeeting:
            {
                UserInfo userInfo = Users.GetInstance().FindUser(socket);

                if (userInfo == null)
                {
                    SetError(ErrorType.Unknown_User, "알수 없는 사용자입니다.");
                    Main.ReplyError(socket);
                    return;
                }

                AskChatInfo askChatInfo = (AskChatInfo)baseInfo;

                UserInfo targetInfo = Users.GetInstance().FindUser(askChatInfo.TargetId);

                if (targetInfo == null)
                {
                    SetError(ErrorType.Unknown_User, "채팅대상이 존재하지 않습니다.");
                    Main.ReplyError(socket);
                    return;
                }

                askChatInfo.TargetId = userInfo.Id;
                server.Send(targetInfo.Socket, NotifyType.Request_EnterMeeting, askChatInfo);
            }
            break;

            case NotifyType.Reply_EnterMeeting:
            {
                AskChatInfo askChatInfo = (AskChatInfo)baseInfo;

                UserInfo targetInfo = Users.GetInstance().FindUser(askChatInfo.TargetId);

                if (targetInfo == null)
                {
                    SetError(ErrorType.Unknown_User, "채팅대상이 존재하지 않습니다.");
                    Main.ReplyError(socket);
                    return;
                }

                if (askChatInfo.Agree == 0)
                {
                    server.Send(targetInfo.Socket, NotifyType.Reply_EnterMeeting, askChatInfo);
                    return;
                }

                RoomInfo meetingInfo = EnterMeeting(socket, askChatInfo);

                if (meetingInfo == null)
                {
                    Main.ReplyError(socket);
                    return;
                }
            }
            break;

            case NotifyType.Request_OutMeeting:
            {
                RoomInfo roomInfo = (RoomInfo)baseInfo;
                UserInfo userInfo = OutMeeting(socket, roomInfo);

                if (userInfo == null)
                {
                    Main.ReplyError(socket);
                }
            }
            break;

            case NotifyType.Request_RoomList:
            {
                UserInfo userInfo = Users.GetInstance().FindUser(socket);

                if (userInfo == null)
                {
                    SetError(ErrorType.Unknown_User, "알수 없는 사용자가 방목록을 요구하였습니다.");
                    Main.ReplyError(socket);
                    return;
                }


                List <RoomInfo> rooms = null;

                if (userInfo.Kind == (int)UserKind.ServiceWoman)
                {
                    rooms = database.GetAllRooms();
                }
                else
                {
                    rooms = GetRooms();
                }

                if (rooms == null)
                {
                    Main.ReplyError(socket);
                    return;
                }

                RoomListInfo roomListInfo = new RoomListInfo();
                roomListInfo.Rooms = rooms;

                server.Send(socket, NotifyType.Reply_RoomList, roomListInfo);
            }
            break;

            case NotifyType.Request_MakeRoom:
            {
                RoomInfo roomInfo = (RoomInfo)baseInfo;

                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    Main.ReplyError(socket);
                    return;
                }

                roomInfo.Owner = userInfo.Id;

                if (database.AddRoom(roomInfo) == false)
                {
                    Main.ReplyError(socket);
                    return;
                }

                string str = string.Format("{0} 님이 방 {1} 을 만들었습니다.", userInfo.Id, roomInfo.Id);
                LogView.AddLogString(str);

                server.Send(socket, NotifyType.Reply_MakeRoom, roomInfo);
                View._isUpdateRoomList = true;

                ReplyRoomList();
            }
            break;

            case NotifyType.Request_UpdateRoom:
            {
                RoomInfo updateInfo = (RoomInfo)baseInfo;

                RoomInfo roomInfo = Database.GetInstance().FindRoom(updateInfo.Id);

                if (roomInfo == null)
                {
                    Main.ReplyError(socket);
                    return;
                }

                roomInfo.Body = updateInfo;

                if (Database.GetInstance().UpdateRoom(roomInfo) == false)
                {
                    Main.ReplyError(socket);
                    return;
                }
                server.Send(socket, NotifyType.Reply_UpdateRoom, roomInfo);
            }
            break;

            case NotifyType.Request_DelRoom:
            {
                RoomInfo delInfo = (RoomInfo)baseInfo;

                if (FindRoom(delInfo.Id) != null)
                {
                    SetError(ErrorType.Live_Room, "유저들이 들어있는 방입니다.");
                    Main.ReplyError(socket);
                    return;
                }

                if (Database.GetInstance().FindRoom(delInfo.Id) == null)
                {
                    SetError(ErrorType.Invalid_RoomId, "삭제하려는 방이 없습니다.");
                    Main.ReplyError(socket);
                    return;
                }

                if (Database.GetInstance().DelRoom(delInfo.Id) == false)
                {
                    Main.ReplyError(socket);
                    return;
                }
                server.Send(socket, NotifyType.Reply_DelRoom, delInfo);
            }
            break;

            case NotifyType.Request_EnterRoom:
            {
                OutRoom(socket);

                RoomInfo enterInfo = (RoomInfo)baseInfo;

                UserInfo userInfo = EnterRoom(socket, enterInfo.Id);

                if (userInfo == null)
                {
                    Main.ReplyError(socket);
                    return;
                }
            }
            break;

            case NotifyType.Request_RoomInfo:
            {
                RoomInfo enterInfo = (RoomInfo)baseInfo;

                UserInfo userInfo = Users.GetInstance().FindUser(socket);

                if (userInfo == null)
                {
                    Main.ReplyError(socket);
                    return;
                }

                //RoomInfo roomInfo = FindRoom(userInfo.RoomId);
                RoomInfo roomInfo = FindRoom(enterInfo.Id);

                if (roomInfo == null)
                {
                    //roomInfo = FindMeeting(userInfo.RoomId);
                    roomInfo = FindMeeting(enterInfo.Id);
                }

                if (roomInfo == null)
                {
                    Main.ReplyError(socket);
                    return;
                }

                roomInfo.Cash = enterInfo.Cash;

                BroadCast(enterInfo.Id, NotifyType.Reply_RoomInfo, enterInfo, null);

                ReplyRoomList();
            }
            break;

            case NotifyType.Request_RoomPrice:
            {
                UserInfo userInfo = Users.GetInstance().FindUser(socket);

                if (userInfo == null)
                {
                    Main.ReplyError(socket);
                    return;
                }

                RoomInfo replyInfo = (RoomInfo)baseInfo;

                bool     bMeeting = false;
                RoomInfo roomInfo = Chat.GetInstance().FindRoom(replyInfo.Id);

                if (roomInfo == null)
                {
                    roomInfo = Chat.GetInstance().FindMeeting(replyInfo.Id);
                    bMeeting = true;
                }

                if (roomInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 선물하려고 합니다.");
                    Main.ReplyError(socket);
                    return;
                }

                if (Cash.GetInstance().ProcessChatCash(userInfo, roomInfo, bMeeting) == false)
                {
                    Main.ReplyError(socket);
                    return;
                }

                userInfo.WaitSecond = -1;
                userInfo.CashTime   = DateTime.Now.AddMinutes(1);
                //BroadCast(roomPrice.RoomId, NotifyType.Reply_RoomPrice, roomPrice, null);
            }
            break;

            case NotifyType.Request_OutRoom:
            {
                if (OutRoom(socket) == null)
                {
                    Main.ReplyError(socket);
                    break;
                }
            }
            break;

            case NotifyType.Request_RoomDetail:
            {
                RoomInfo roomInfo = (RoomInfo)baseInfo;

                ReplyRoomDetailInfo(roomInfo.Id);
            }
            break;

            case NotifyType.Request_StringChat:
            {
                StringInfo stringInfo = (StringInfo)baseInfo;

                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다.");
                    Main.ReplyError(socket);
                    return;
                }

                stringInfo.UserId = userInfo.Id;

                //BroadCast(userInfo.RoomId, NotifyType.Reply_StringChat, stringInfo, null );
                BroadCast(stringInfo.strRoomID, NotifyType.Reply_StringChat, stringInfo, stringInfo.UserId);
            }
            break;

            case NotifyType.Request_SendIP:
            {
                AVMsg avMsg = (AVMsg)baseInfo;

                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다.");
                    Main.ReplyError(socket);
                    return;
                }

                BroadCast(avMsg._strRoomID, NotifyType.Reply_SendIP, avMsg, userInfo.Id);
            }
            break;

            case NotifyType.Request_VideoInfo:
            {
                AVMsg avMsg = (AVMsg)baseInfo;

                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다.");
                    Main.ReplyError(socket);
                    return;
                }

                BroadCast(avMsg._strRoomID, NotifyType.Reply_VideoInfo, avMsg, userInfo.Id);
            }
            break;

            case NotifyType.Request_VoiceChat:
            {
                VoiceInfo voiceInfo = (VoiceInfo)baseInfo;

                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다.");
                    Main.ReplyError(socket);
                    return;
                }

                voiceInfo.UserId = userInfo.Id;

                BroadCast(userInfo.RoomId, NotifyType.Reply_VoiceChat, voiceInfo, userInfo.Id);
            }
            break;

            case NotifyType.Request_VideoChat:
            {
                VideoInfo videoInfo = (VideoInfo)baseInfo;

                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 채팅하려고 합니다.");
                    Main.ReplyError(socket);
                    return;
                }

                videoInfo.UserId = userInfo.Id;

                BroadCast(userInfo.RoomId, NotifyType.Reply_VideoChat, videoInfo, userInfo.Id);
            }
            break;

            case NotifyType.Request_Give:
            {
                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "알수 없는 사용자가 선물하려고 합니다.");
                    Main.ReplyError(socket);
                    return;
                }

                PresentHistoryInfo presentInfo = (PresentHistoryInfo)baseInfo;
                presentInfo.SendId = userInfo.Id;

                UserInfo targetInfo = database.FindUser(presentInfo.ReceiveId);

                if (targetInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "받으려는 사용자정보가 정확치 않습니다.");
                    Main.ReplyError(socket);
                    return;
                }

                if (Cash.GetInstance().ProcessPresent(presentInfo) == false)
                {
                    Main.ReplyError(socket);
                    return;
                }

                //BroadCast(userInfo.RoomId, NotifyType.Reply_Give, baseInfo, null);
                BroadCast(presentInfo.strRoomID, NotifyType.Reply_Give, baseInfo, null);

                //ReplyRoomDetailInfo(userInfo.RoomId);

                users.ReplyUserList(null);

                View._isUpdateUserList = true;
            }
            break;

            case NotifyType.Request_MusiceInfo:
            {
                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "不明会员准备删除过照片信息.");
                    Main.ReplyError(socket);
                    return;
                }

                MusiceInfo musiceInfo = (MusiceInfo)baseInfo;

                BroadCast(userInfo.RoomId, NotifyType.Reply_MusiceInfo, musiceInfo, null);
                //server.Send(socket, NotifyType.Reply_MusiceInfo, musiceInfo);
            }
            break;

            case NotifyType.Request_MusiceStateInfo:
            {
                UserInfo userInfo = users.FindUser(socket);

                if (userInfo == null)
                {
                    BaseInfo.SetError(ErrorType.Unknown_User, "不明会员准备删除过照片信息.");
                    Main.ReplyError(socket);
                    return;
                }

                MusiceStateInfo musiceStateInfo = (MusiceStateInfo)baseInfo;

                BroadCast(userInfo.RoomId, NotifyType.Reply_MusiceStateInfo, musiceStateInfo, null);
                //server.Send(socket, NotifyType.Reply_MusiceStateInfo, musiceStateInfo);
            }
            break;
            }
        }