private void AddDummyOnlineUser(int roomLevel, int deskNo) { OnlineUser onlineUser = new OnlineUser(); onlineUser.UniqueID = OnlineHttpModule.GetDummyUniqueID(_minDummyUserId); // 用户名称 onlineUser.UserName = Guid.NewGuid().ToString("N"); // 用户头像 onlineUser.Avatar = GetRandomAvatar(); onlineUser.RoomLevel = roomLevel; onlineUser.DeskNo = deskNo; onlineUser.Num = OnlineHttpModule.GetMinMotoNum(roomLevel, deskNo); // 保存用户信息 OnlineHttpModule.AddOnlineUser(onlineUser); }
/// <summary> /// 进入房间 /// </summary> /// <param name="model">room model</param> /// <returns></returns> public JsonResult Join(RoomUserModel model) { var result = new ResponseResult(); try { var user = PKBag.OnlineUserRecorder.GetUser(PKBag.LoginUser.UserName); if (user.RoomLevel == model.RoomLevel && user.DeskNo == model.DeskNo) { //已经进入的房间 } else { var maxMembers = 10; //最多人数 var deskUsers = PKBag.OnlineUserRecorder.GetUsers(model.RoomLevel, model.DeskNo); var memberCount = deskUsers.Count(); if (memberCount == maxMembers) { result.Success = false; result.Message = "房间已满"; } else { user.RoomLevel = model.RoomLevel; user.DeskNo = model.DeskNo; // 取最小的 还未在房间中 使用的车号 var motoNums = OnlineHttpModule.GetMinMotoNum(model.RoomLevel, model.DeskNo); user.Num = motoNums; } } } catch (Exception ex) { result.Success = false; result.Message = MessageConst.System_Error; _logger.Info(ex); } return(Json(result)); }