Inheritance: global::ProtoBuf.IExtensible
 private void HandleUserDrop(Msg_RL_UserDrop msg, PBChannel channel, int src, uint session)
 {
     //响应RoomServer游戏客户端退出消息
     m_RoomProcessThread.OnRoomUserDrop(msg.RoomID, msg.UserGuid, msg.IsBattleEnd, msg);
 }
 private void HandleUserDrop(Msg_RL_UserDrop msg_, PBChannel channel, int src, uint session)
 {
 }
Ejemplo n.º 3
0
        internal void Tick()
        {
            try {
                if (this.CurrentState != RoomState.Active && this.CurrentState != RoomState.Finish)
                    return;

                long curTime = TimeUtility.GetLocalMilliseconds();
                if (m_LastLogTime + 60000 < curTime) {
                    m_LastLogTime = curTime;

                    LogSys.Log(LOG_TYPE.INFO, "Room.Tick {0}", RoomID);
                }

                if (this.CurrentState == RoomState.Active) {
                    Scene scene = ActiveScene;
                    if (null != scene) {
                        scene.Tick();
                    }
                    disconnected_users_.Clear();
                    request_delete_users_.Clear();
                    foreach (User user in room_users_) {
                        if (user != null) {
                            user.Tick();
                            if (user.IsTimeout()) {
                                if (user.UserControlState == (int)UserControlState.User) {
                                    disconnected_users_.Add(user);
                                } else if (user.UserControlState == (int)UserControlState.Remove) {
                                    request_delete_users_.Add(user);
                                } else if (user.UserControlState == (int)UserControlState.UserDropped) {
                                    if (user.LastNotifyUserDropTime + c_NotifyUserDropInterval < curTime) {
                                        Msg_RL_UserDrop uaqBuilder = new Msg_RL_UserDrop();
                                        uaqBuilder.RoomID = cur_room_id_;
                                        uaqBuilder.UserGuid = user.Guid;
                                        uaqBuilder.IsBattleEnd = false;
                                        connector_.SendMsgToLobby(uaqBuilder);

                                        user.LastNotifyUserDropTime = curTime;
                                    }
                                    //临时处理,踢掉断线的玩家
                                    user.UserControlState = (int)UserControlState.Remove;
                                }
                            }
                        }
                    }
                    foreach (User user in disconnected_users_) {
                        DropUser(user);
                    }
                    foreach (User user in request_delete_users_) {
                        RemoveUser(user);
                    }
                    //todo:观察者掉线处理
                    for (int i = 0; i < room_observers_.Length; ++i) {
                        Observer observer = room_observers_[i];
                        if (!observer.IsIdle) {
                            observer.Tick();
                        }
                    }
                    if (!IsFieldRoom) {
                        int userCount = GetActiveRoomUserCount();
                        if (userCount <= 0 && CanFinish) {
                            if (GetMinimizeElapsedDroppedTime() > c_finish_time_for_no_users_) {
                                //若房间内玩家数目为0,结束战斗,关闭房间
                                Finish((int)CampIdEnum.Unkown);
                            }
                        }
                    }
                    //每个Tick结束,将空间属性同步给Peer,用于Peer转发消息
                    foreach (User user in room_users_) {
                        if (null != user && null != user.Info && null != user.Info.GetMovementStateInfo()) {
                            RoomServer.RoomPeer peer = user.GetPeer();
                            if (null != peer) {
                                MovementStateInfo info = user.Info.GetMovementStateInfo();
                                peer.Position = info.GetPosition3D();
                                peer.FaceDir = info.GetFaceDir();
                            }
                        }
                    }
                } else if (m_FinishTime + c_DeactiveWaitTime < curTime) {
                    Deactive();
                }
            } catch (Exception ex) {
                LogSys.Log(LOG_TYPE.ERROR, "Exception {0}\n{1}", ex.Message, ex.StackTrace);
            }
        }
Ejemplo n.º 4
0
 internal void NoticeRoomClosing()
 {
     foreach (User user in room_users_) {
         if (user != null && (int)UserControlState.UserDropped == user.UserControlState) {
             Msg_RL_UserDrop unqBuilder = new Msg_RL_UserDrop();
             unqBuilder.RoomID = cur_room_id_;
             unqBuilder.UserGuid = user.Guid;
             unqBuilder.IsBattleEnd = true;
             connector_.SendMsgToLobby(unqBuilder);
             user.LastNotifyUserDropTime = TimeUtility.GetLocalMilliseconds();
         }
     }
 }
Ejemplo n.º 5
0
 internal void Finish(int winnerCampID)
 {
     if (IsFieldRoom) {
         return;
     }
     if (this.CurrentState == RoomState.Finish || this.CurrentState == RoomState.Deactive) {
         return;
     }
     foreach (User user in room_users_) {
         if (user != null) {
             Msg_RL_UserDrop unqBuilder = new Msg_RL_UserDrop();
             unqBuilder.RoomID = cur_room_id_;
             unqBuilder.UserGuid = user.Guid;
             unqBuilder.IsBattleEnd = true;
             connector_.SendMsgToLobby(unqBuilder);
             user.LastNotifyUserDropTime = TimeUtility.GetLocalMilliseconds();
         }
     }
     this.CurrentState = RoomState.Finish;
     m_FinishTime = TimeUtility.GetLocalMilliseconds();
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0}({1}) EndBattle.", RoomID, LocalID);
 }
Ejemplo n.º 6
0
 internal void DropUser(User user)
 {
     //向Lobby发送玩家掉线消息
     Msg_RL_UserDrop uaqBuilder = new Msg_RL_UserDrop();
     uaqBuilder.RoomID = cur_room_id_;
     uaqBuilder.UserGuid = user.Guid;
     uaqBuilder.IsBattleEnd = false;
     connector_.SendMsgToLobby(uaqBuilder);
     user.LastNotifyUserDropTime = TimeUtility.GetLocalMilliseconds();
     //控制状态改为掉线
     user.UserControlState = (int)UserControlState.UserDropped;
     if (null != user.Info) {
         // user.Info.Suicide();
     }
     LogSys.Log(LOG_TYPE.DEBUG, "Room {0} User {1}({2}) dropped.", RoomID, user.Guid, user.GetKey());
 }
        //响应RoomServer发来的房间内玩家掉线消息
        internal void OnRoomUserDrop(int roomid, ulong guid, bool isBattleEnd, Msg_RL_UserDrop originalMsg)
        {
            UserInfo user = LobbyServer.Instance.UserProcessScheduler.GetUserInfo(guid);
            if (user != null) {
                if (isBattleEnd) {
                    user.CurrentRoomID = 0;
                    user.CurrentState = UserState.Room == user.CurrentState ? UserState.Online : user.CurrentState;
                } else {
                    user.CurrentRoomID = roomid;
                }
                RoomInfo curRoom = user.Room;
                RoomInfo oldRoom = m_LobbyInfo.GetRoomByID(roomid);
                if (null != oldRoom && oldRoom != curRoom) {
                    Msg_LR_UserQuit msg = new Msg_LR_UserQuit();
                    msg.UserGuid = guid;
                    msg.RoomID = roomid;
                    LobbyServer.Instance.RoomSvrChannel.Send(oldRoom.RoomServerName, msg);
                }
                LobbyServer.Instance.ForwardToWorld(user.UserSvrName, originalMsg);

                LogSys.Log(LOG_TYPE.INFO, "RoomServer User Drop! Guid {0} State {1} IsEnd {2}", guid, user.CurrentState, isBattleEnd);
            } else {
                RoomInfo oldRoom = m_LobbyInfo.GetRoomByID(roomid);
                if (null != oldRoom) {
                    Msg_LR_UserQuit msg = new Msg_LR_UserQuit();
                    msg.UserGuid = guid;
                    msg.RoomID = roomid;
                    LobbyServer.Instance.RoomSvrChannel.Send(oldRoom.RoomServerName, msg);
                }

                LogSys.Log(LOG_TYPE.INFO, "RoomServer User Drop! Guid {0} State Offline IsEnd {1}", guid, isBattleEnd);
            }
        }