protected UserInfo GetUserByWebSocket(WebSocket socket) { var connMgr = AppServer.Instance.connManager; var socketid = connMgr.GetId(socket); return(UserMgr.GetUser(socketid)); }
public void NotifyInDisConnectClient(ServerPacketData requestData) { var sessionIndex = requestData.SessionIndex; var user = UserMgr.GetUser(sessionIndex); if (user != null) { var roomNum = user.RoomNumber; if (roomNum != PacketDef.INVALID_ROOM_NUMBER) { var packet = new PKTInternalNtfRoomLeave() { RoomNumber = roomNum, UserID = user.ID(), }; var packetBodyData = MessagePackSerializer.Serialize(packet); var internalPacket = new ServerPacketData(); internalPacket.Assign("", sessionIndex, (Int16)PACKETID.NTF_IN_ROOM_LEAVE, packetBodyData); ServerNetwork.Distribute(internalPacket); } UserMgr.RemoveUser(sessionIndex); } MainServer.MainLogger.Debug($"Current Connected Session Count: {ServerNetwork.SessionCount}"); }
bool LeaveRoomUser(int sessionIndex, int roomNumber) { MainServer.MainLogger.Debug($"LeaveRoomUser. SessionIndex:{sessionIndex}"); var room = GetRoom(roomNumber); if (room == null) { return(false); } var roomUser = room.GetUser(sessionIndex); if (roomUser == null) { return(false); } var user = UserMgr.GetUser(sessionIndex); user.EnteredRoom(-1);// 룸 초기화 var userID = roomUser.UserID; room.RemoveUser(roomUser); room.NotifyPacketLeaveUser(userID); return(true); }
public void NotifyInDisConnectClient(EFBinaryRequestInfo requestData) { var sessionID = requestData.SessionID; var user = UserMgr.GetUser(sessionID); if (user != null) { var roomNum = user.RoomNumber; if (roomNum != PacketDef.INVALID_ROOM_NUMBER) { var packet = new PKTInternalNtfRoomLeave() { RoomNumber = roomNum, UserID = user.ID(), }; var packetBodyData = MessagePackSerializer.Serialize(packet); var internalPacket = new ServerPacketData(); internalPacket.Assign(sessionID, (Int16)PACKETID.NTF_IN_ROOM_LEAVE, packetBodyData); DistributePacket(internalPacket); } UserMgr.RemoveUser(sessionID); } }
public void Login(HttpContext context) { string name = context.Request["name"]; string pwd = context.Request["pwd"]; User user = UserMgr.GetUser(name, pwd); //返回json格式 if (null != user) { context.Response.Write("{\"status\":true,\"msg\":\"欢迎使用xxxx\"}"); } else { context.Response.Write("{\"status\":false,\"msg\":\"不存在该用户或密码错误,请注册或找回密码\"}"); } }
public void RequestLogin(ServerPacketData packetData) { var sessionID = packetData.SessionID; var sessionIndex = packetData.SessionIndex; MainServer.MainLogger.Debug("로그인 요청 받음"); try { if (UserMgr.GetUser(sessionIndex) != null) { ResponseLoginToClient(ERROR_CODE.LOGIN_ALREADY_WORKING, packetData.SessionID); return; } var reqData = MessagePackSerializer.Deserialize <PKTReqLogin>(packetData.BodyData); var errorCode = UserMgr.AddUser(reqData.UserID, packetData.SessionID, packetData.SessionIndex); if (errorCode != ERROR_CODE.NONE) { ResponseLoginToClient(errorCode, packetData.SessionID); if (errorCode == ERROR_CODE.LOGIN_FULL_USER_COUNT) { NotifyMustCloseToClient(ERROR_CODE.LOGIN_FULL_USER_COUNT, packetData.SessionID); } return; } ResponseLoginToClient(errorCode, packetData.SessionID); MainServer.MainLogger.Debug("로그인 요청 답변 보냄"); } catch (Exception ex) { // 패킷 해제에 의해서 로그가 남지 않도록 로그 수준을 Debug로 한다. MainServer.MainLogger.Error(ex.ToString()); } }
public void RequestLeave(ServerPacketData packetData) { var sessionID = packetData.SessionID; var sessionIndex = packetData.SessionIndex; MainServer.MainLogger.Debug("RequestLeave"); try { var user = UserMgr.GetUser(sessionIndex); if (user == null) { return; } if (LeaveRoomUser(sessionIndex, user.RoomNumber) == false) { return; } } catch (Exception e) { } }