Exemple #1
0
        private void AddAuto_Load(object sender, EventArgs e)
        {
            List <RoomInfo> roomList = Chat.GetInstance().GetRooms();

            comboRoom.Items.Add("不使用");
            comboRoom.Items.Add("选择频道");

            foreach (RoomInfo roomInfo in roomList)
            {
                comboRoom.Items.Add(roomInfo.Id);
            }

            comboRoom.SelectedIndex = 1;

            List <GameTable> gameList = Game.GetInstance().GetGameTables();

            comboGame.Items.Add("不使用");
            comboGame.Items.Add("选择频道");

            foreach (GameTable gameTable in gameList)
            {
                comboGame.Items.Add(gameTable._GameInfo.GameId);
            }

            comboGame.SelectedIndex = 1;

            _PossibleCount = Auto.GetInstance().GetLiveCount();

            textAutoNum.Text = _PossibleCount.ToString();
        }
Exemple #2
0
        public void NotifyCash()
        {
            List <RoomInfo> meetList = Chat.GetInstance().GetMeetings();

            if (meetList != null)
            {
                for (int i = 0; i < meetList.Count; i++)
                {
                    RoomInfo meetInfo = meetList[i];

                    if (meetInfo.Cash == 0)
                    {
                        continue;
                    }

                    List <UserInfo> users = Users.GetInstance().GetRoomUsers(meetInfo.Id);

                    for (int k = 0; k < users.Count; k++)
                    {
                        UserInfo userInfo = users[k];

                        if (userInfo.WaitSecond == 0)
                        {
                            continue;
                        }

                        if (DateTime.Now <= userInfo.CashTime)
                        {
                            continue;
                        }

                        ProcessChatCash(userInfo, meetList[i], true);
                    }
                }
            }

            //List<RoomInfo> roomList = Chat.GetInstance().GetRooms();

            //if (roomList != null)
            //{
            //    for (int i = 0; i < roomList.Count; i++)
            //        ProcessChatCash(roomList[i], false );
            //}
        }
Exemple #3
0
        private void Loginuser_Load(object sender, EventArgs e)
        {
            string configPath = System.IO.Path.GetFullPath("Config.ini");

            IniFileEdit configInfo = new IniFileEdit(configPath);

            Database._IP         = configInfo.GetIniValue("Database", "IP");
            Users.WebResourceUrl = configInfo.GetIniValue("Web", "Resource");

            // server initialize
            string port = configInfo.GetIniValue("Chatting", "TcpPort");

            Server server = Server.GetInstance();

            server.AttachHandler(Users.GetInstance().NotifyOccured);
            server.AttachHandler(Chat.GetInstance().NotifyOccured);
            server.AttachHandler(Game.GetInstance().NotifyOccured);

            server.Connect("127.0.0.1", port);
        }
Exemple #4
0
        private void AddAuto_Load(object sender, EventArgs e)
        {
            List <RoomInfo> roomList = Chat.GetInstance().GetRooms();

            comboRoom.Items.Add("不使用");
            comboRoom.Items.Add("选择频道");

            foreach (RoomInfo roomInfo in roomList)
            {
                comboRoom.Items.Add(roomInfo.Id);
            }

            comboRoom.SelectedIndex = 1;

            List <GameInfo> gameList = Database.GetInstance().GetAllGames();

            comboGame.Items.Add("不使用");
            comboGame.Items.Add("选择频道");

            //foreach (GameInfo gameInfo in gameList)
            //    comboGame.Items.Add(gameInfo.GameId);
            // modified by usc at 2014/02/21
            foreach (GameInfo gameInfo in gameList)
            {
                comboGame.Items.Add(gameInfo.GameId);

                int nPointGameId = Convert.ToInt32(gameInfo.GameId) + 1;

                comboGame.Items.Add(nPointGameId.ToString());
            }

            comboGame.SelectedIndex = 1;

            int liveCount = Auto.GetInstance().GetLiveCount();
            int autoCount = Auto.GetInstance().GetAutoCount();

            _PossibleCount = autoCount - liveCount;

            textAutoNum.Text = _PossibleCount.ToString();
        }
Exemple #5
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            int addCount = 0;

            try
            {
                addCount = Convert.ToInt32(textAutoNum.Text);
            }
            catch { }

            if (addCount <= 0 || addCount > _PossibleCount)
            {
                MessageBox.Show("请输入准确数量.");
                return;
            }

            lock (Server.GetInstance()._objLockMain)
            {
                List <UserInfo> autoList = Database.GetInstance().GetAutoList();
                Random          random   = new Random();

                if (comboRoom.SelectedIndex > 0)
                {
                    List <RoomInfo> roomList = new List <RoomInfo>();

                    if (comboRoom.SelectedIndex > 1)
                    {
                        roomList.Add(Chat.GetInstance().FindRoom(comboRoom.Text));
                    }
                    else
                    {
                        roomList = Database.GetInstance().GetAllRooms();
                    }
                    //roomList = Chat.GetInstance().GetRooms();

                    foreach (RoomInfo roomInfo in roomList)
                    {
                        if (roomInfo.MaxUsers <= 0)
                        {
                            continue;
                        }

                        int roomAddCount = 0;

                        if (roomList.Count == 1)
                        {
                            roomAddCount = addCount;

                            if (roomAddCount > roomInfo.MaxUsers - roomInfo.UserCount)
                            {
                                roomAddCount = roomInfo.MaxUsers - roomInfo.UserCount;
                            }
                        }
                        else
                        {
                            roomAddCount = random.Next() % (roomInfo.MaxUsers - roomInfo.UserCount);

                            if (roomAddCount > addCount)
                            {
                                roomAddCount = addCount;
                            }
                        }


                        bool isEmpty = false;

                        if (roomInfo.UserCount == 0)
                        {
                            isEmpty = true;
                        }

                        while (roomAddCount > 0 && autoList.Count > 0)
                        {
                            UserInfo userInfo = autoList[0];

                            if (isEmpty == true && userInfo.Kind != (int)UserKind.ServiceWoman)
                            {
                                break;
                            }

                            autoList.RemoveAt(0);

                            if (Auto.GetInstance().GetAuto(userInfo.Id) != null)
                            {
                                continue;
                            }

                            Auto.GetInstance().AddAuto(roomInfo, userInfo);

                            roomAddCount--;
                            addCount--;
                        }

                        if (addCount <= 0)
                        {
                            break;
                        }

                        if (autoList.Count <= 0)
                        {
                            break;
                        }
                    }
                }



                if (comboGame.SelectedIndex > 0)
                {
                    List <GameInfo> gameList = new List <GameInfo>();

                    //if (comboGame.SelectedIndex > 1)
                    //    gameList.Add(Database.GetInstance().FindGame(comboGame.Text));
                    //else
                    //    gameList = Database.GetInstance().GetAllGames();
                    if (comboGame.SelectedIndex > 1)
                    {
                        // modified by usc at 2014/02/23
                        int nGameId = 0;

                        if (comboGame.SelectedIndex % 2 == 0)
                        {
                            nGameId = Convert.ToInt32(comboGame.Text);      // cash game
                        }
                        else
                        {
                            nGameId = Convert.ToInt32(comboGame.Text) - 1;  // point game
                        }
                        gameList.Add(Database.GetInstance().FindGame(nGameId.ToString()));
                    }
                    else
                    {
                        gameList = Database.GetInstance().GetAllGames();
                    }


                    foreach (GameInfo gameInfo in gameList)
                    {
                        int gameAddCount = random.Next() % 5 + 5;

                        if (gameList.Count == 1)
                        {
                            gameAddCount = addCount;
                        }

                        if (gameAddCount > addCount)
                        {
                            gameAddCount = addCount;
                        }

                        while (gameAddCount > 0 && autoList.Count > 0)
                        {
                            int nCashOrPoint = 0;

                            UserInfo userInfo = autoList[0];
                            autoList.RemoveAt(0);

                            if (Auto.GetInstance().GetAuto(userInfo.Id) != null)
                            {
                                continue;
                            }

                            // added by usc at 2014/02/23
                            if (comboGame.SelectedIndex > 1)
                            {
                                nCashOrPoint = comboGame.SelectedIndex % 2;
                            }
                            else
                            {
                                nCashOrPoint = random.Next() % 2;
                            }

                            if (nCashOrPoint == 0)
                            {
                                gameInfo.nCashOrPointGame = 0;

                                Auto.GetInstance().AddAuto(gameInfo, userInfo, true);
                            }
                            else
                            {
                                GameInfo pointGameInfo = new GameInfo();

                                pointGameInfo._NotifyHandler   = gameInfo._NotifyHandler;
                                pointGameInfo.Bank             = gameInfo.Bank;
                                pointGameInfo.Commission       = gameInfo.Commission;
                                pointGameInfo.GameId           = (Convert.ToInt32(gameInfo.GameId) + 1).ToString();
                                pointGameInfo.GameName         = gameInfo.GameName;
                                pointGameInfo.Height           = gameInfo.Height;
                                pointGameInfo.Icon             = gameInfo.Icon;
                                pointGameInfo.nCashOrPointGame = 1;
                                pointGameInfo.Source           = gameInfo.Source;
                                pointGameInfo.UserCount        = gameInfo.UserCount;
                                pointGameInfo.Width            = gameInfo.Width;

                                Auto.GetInstance().AddAuto(pointGameInfo, userInfo, true);
                            }

                            gameAddCount--;
                            addCount--;
                        }

                        if (addCount <= 0)
                        {
                            break;
                        }

                        if (autoList.Count <= 0)
                        {
                            break;
                        }
                    }
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Exemple #6
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;
            }
        }
Exemple #7
0
        public bool ProcessChatCash(UserInfo userInfo, RoomInfo roomInfo, bool bMeeting)
        {
            //List<UserInfo> users = Users.GetInstance().GetRoomUsers(roomInfo.Id);

            //if (users == null)
            //{
            //    ErrorView.AddErrorString();
            //    return false;
            //}

            //bool bUpdate = false;

            //for (int i = 0; i < users.Count; i++)
            //{
            //    UserInfo userInfo = users[i];

            if (userInfo.Kind == (int)UserKind.Manager ||
                userInfo.Kind == (int)UserKind.ServiceWoman ||
                userInfo.Kind == (int)UserKind.ServiceOfficer)
            {
                return(true);
            }

            //bUpdate = true;

            if (roomInfo.Cash > 0)
            {
                if (GiveChatSum(userInfo.Id, -roomInfo.Cash) == false)
                {
                    Chat.GetInstance().OutMeeting(userInfo.Socket, roomInfo);
                    return(false);
                }

                if (userInfo.Auto > 0)
                {
                    return(true);
                }

                //GiveChatSum(userInfo.Id, -roomInfo.Cash);

                if (bMeeting == true)
                {
                    userInfo.CashTime = userInfo.CashTime.AddMinutes(1);
                }
                else
                {
                    userInfo.CashTime = userInfo.CashTime.AddYears(1);
                }

                UserInfo servicer       = Database.GetInstance().FindUser(roomInfo.Owner);
                UserInfo serviceOfficer = Database.GetInstance().FindUser(servicer.Recommender); // Database.GetInstance().GetManager(UserKind.ServiceOfficer);
                UserInfo manager        = Database.GetInstance().GetManager(UserKind.Manager)[0];

                int servicePercent        = servicer.ChatPercent;
                int serviceOfficerPercent = serviceOfficer.ChatPercent;

                if (servicePercent > 100)
                {
                    servicePercent = 100;
                }

                if (serviceOfficerPercent > 100)
                {
                    serviceOfficerPercent = 100;
                }

                if (servicePercent > serviceOfficerPercent)
                {
                    servicePercent = serviceOfficerPercent;
                }

                serviceOfficerPercent -= servicePercent;

                int serviceCash        = ProcessCashPercent(servicer, servicePercent, roomInfo.Cash);
                int serviceOfficerCash = ProcessCashPercent(serviceOfficer, serviceOfficerPercent, roomInfo.Cash);
                int managerCash        = roomInfo.Cash - serviceOfficerCash - serviceCash;

                if (servicer != null)
                {
                    GiveChatSum(servicer.Id, serviceCash);
                }

                if (serviceOfficer != null)
                {
                    GiveChatSum(serviceOfficer.Id, serviceOfficerCash);
                }

                GiveChatSum(manager.Id, managerCash);

                ChatHistoryInfo chatHistoryInfo = Database.GetInstance().FindChatHistory(userInfo.ChatHistoryId);

                if (chatHistoryInfo != null)
                {
                    chatHistoryInfo.OfficerId = serviceOfficer.Id;
                    chatHistoryInfo.ManagerId = manager.Id;

                    chatHistoryInfo.BuyerTotal          -= roomInfo.Cash;
                    chatHistoryInfo.ServicemanTotal     += serviceCash;
                    chatHistoryInfo.ServiceOfficerTotal += serviceOfficerCash;
                    chatHistoryInfo.ManagerTotal        += managerCash;
                    chatHistoryInfo.EndTime              = DateTime.Now;

                    Database.GetInstance().UpdateChatHistory(chatHistoryInfo);
                }

                View._isUpdateRoomList = true;
            }

            if (roomInfo.Point > 0)
            {
                if (userInfo.Point < roomInfo.Point)
                {
                    SetError(ErrorType.Notenough_Point, string.Format("因{0}的账号余额不足 退出聊天频道.", userInfo.Id));
                    Main.ReplyError(userInfo.Socket);

                    Chat.GetInstance().OutMeeting(userInfo.Socket, roomInfo);
                    return(false);
                }

                UserInfo updateInfo = Database.GetInstance().FindUser(userInfo.Id);

                if (updateInfo == null)
                {
                    Chat.GetInstance().OutMeeting(userInfo.Socket, roomInfo);
                    return(false);
                }

                updateInfo.Point -= roomInfo.Point;

                if (Database.GetInstance().UpdateUser(updateInfo) == false)
                {
                    Chat.GetInstance().OutMeeting(userInfo.Socket, roomInfo);
                    return(false);
                }

                userInfo.Point = updateInfo.Point;

                PointHistoryInfo pointHistoryInfo = Database.GetInstance().FindPointHistory(userInfo.PointHistoryId);

                if (pointHistoryInfo != null)
                {
                    pointHistoryInfo.Point    -= roomInfo.Point;
                    pointHistoryInfo.AgreeTime = DateTime.Now;

                    Database.GetInstance().UpdatePointHistory(pointHistoryInfo);
                }

                userInfo.CashTime = userInfo.CashTime.AddMinutes(1);

                View._isUpdateUserList = true;
                View._isUpdateRoomList = true;
            }
            //}

            //if( bUpdate == true )
            Chat.GetInstance().ReplyRoomDetailInfo(roomInfo.Id);

            return(true);
        }