public ChatGiftSubscriptionMessage(string channel, string messageId, int months, PublicUserData giftingUser, PublicUserData receiveingUser, RoomRole receiverRoomRole) : base(ChatEventType.GIFTSUB, channel, messageId) { Months = months; GiftingUser = giftingUser; ReceivingUser = receiveingUser; ReceiverRoomRole = receiverRoomRole; }
public RoomRoleViewModel(RoomRole roomRole) : base(roomRole) { roomId.SetValue(roomRole.Room_Id); userId.SetValue(roomRole.User_Id); roleId.SetValue(roomRole.Role_Id); }
public ChatBanMessage(string channel, string messageId, PublicUserData bannedUser, RoomRole bannedRoomRole, PublicUserData admin, RoomRole adminRoomRole) : base(ChatEventType.BAN, channel, messageId) { BannedUser = bannedUser; BannedRoomRole = bannedRoomRole; Admin = admin; AdminRoomRole = adminRoomRole; }
public ChatTimeoutMessage(string channel, string messageId, int duration, PublicUserData timedoutUser, RoomRole timedoutRoomRole, PublicUserData admin, RoomRole adminRoomRole) : base(ChatEventType.TIMEOUT, channel, messageId) { TimeoutMinutes = duration; TimedoutUser = timedoutUser; TimedoutRoomRole = timedoutRoomRole; Admin = admin; AdminRoomRole = adminRoomRole; }
private void DoCommand(int roomId, int cmdId, UserNCallback sourceUser, int targetUserId) { var adminId = BuiltIns._9258Administrator.Id; switch (cmdId) { case Applications._9258App.UserCommands.AddToBlackListCommandId: dataServiceClient.AddBlockList(sourceUser.User.Id, sourceUser.DataServiceToken, new BlockList { Application_Id = ApplicationId, BlockType_Id = BuiltIns.BlackListType.Id, Content = targetUserId.ToString() }); break; case Applications._9258App.UserCommands.BlockUserIdCommandId: dataServiceClient.AddBlockList(sourceUser.User.Id, sourceUser.DataServiceToken, new BlockList { Application_Id = ApplicationId, BlockType_Id = BuiltIns.BlockUserType.Id, Content = targetUserId.ToString() }); break; case Applications._9258App.UserCommands.BlockUserIpCommandId: dataServiceClient.AddBlockList(sourceUser.User.Id, sourceUser.DataServiceToken, new BlockList { Application_Id = ApplicationId, BlockType_Id = BuiltIns.BlockIPType.Id, Content = targetUserId.ToString() }); break; case Applications._9258App.UserCommands.BlockUserMacCommandId: dataServiceClient.AddBlockList(sourceUser.User.Id, sourceUser.DataServiceToken, new BlockList { Application_Id = ApplicationId, BlockType_Id = BuiltIns.BlockMacType.Id, Content = targetUserId.ToString() }); break; case Applications._9258App.UserCommands.SetOrCancelRoomManagerCommandId: var rr = dataServiceClient.GetRoomRole(sourceUser.User.Id, sourceUser.DataServiceToken, roomId, targetUserId, BuiltIns._9258RoomAdministratorRole.Id); if (rr == null) { rr = new RoomRole { Room_Id = roomId, User_Id = targetUserId, Role_Id = BuiltIns._9258RoomAdministratorRole.Id }; dataServiceClient.AddRoomRole(sourceUser.User.Id, sourceUser.DataServiceToken, rr); cache.AddRoomRole(rr); } else { dataServiceClient.DeleteRoomRole(sourceUser.User.Id, sourceUser.DataServiceToken, roomId, targetUserId, BuiltIns._9258RoomAdministratorRole.Id); cache.RemoveRoomRole(roomId, BuiltIns._9258RoomAdministratorRole.Id, targetUserId); } break; case Applications._9258App.UserCommands.UpDownUserPrivateMicCommandId: case Applications._9258App.UserCommands.UpDownUserPublicMicCommandId: case Applications._9258App.UserCommands.BlockHornHallHornCommandId: case Applications._9258App.UserCommands.AllowConnectPrivateMicCommandId: case Applications._9258App.UserCommands.AllowConnectSecretMicCommandId: case Applications._9258App.UserCommands.KickOutOfRoomCommandId: break; } }
public RoomRoleModel(RoomRole roomR) : base(roomR) { if (roomR != null) { Room_Id = roomR.Room_Id; User_Id = roomR.User_Id; Role_Id = roomR.Role_Id; } }
public ActionResult Edit([Bind(Include = "RoomID,BuildingID,Floor,Capacity,RoomCode,DefaultBookingStatusID,MaximumBookingHours,Name,Description,ImgUrl")] Room room, string AllowedGroups, string Assets) { try { if (ModelState.IsValid) { db.Entry(room).State = EntityState.Modified; db.SaveChanges(); foreach (RoomRole rr in db.RoomRoles.Where(rro => rro.RoomID == room.RoomID).ToList()) { db.RoomRoles.Remove(rr); db.SaveChanges(); } foreach (RoomAsset ra in db.RoomAssets.Where(rao => rao.RoomID == room.RoomID).ToList()) { db.RoomAssets.Remove(ra); db.SaveChanges(); } var allGroups = System.Web.Helpers.Json.Decode <List <string> >(Server.UrlDecode(AllowedGroups)); foreach (string gr in allGroups) { RoomRole rr = new RoomRole() { AspNetRoleID = gr, RoomID = room.RoomID }; db.RoomRoles.Add(rr); db.SaveChanges(); } var asst = System.Web.Helpers.Json.Decode <List <Dictionary <string, string> > >(Server.UrlDecode(Assets)); foreach (Dictionary <string, string> asset in asst) { RoomAsset ra = new RoomAsset() { AssetID = Convert.ToInt32(asset["id"]), Description = asset["description"], RoomID = room.RoomID }; db.RoomAssets.Add(ra); db.SaveChanges(); } return(RedirectToAction("Index")); } ViewBag.DefaultBookingStatusID = new SelectList(db.BookingStatuses, "BookingStatusID", "Name", room.DefaultBookingStatusID); ViewBag.BuildingID = new SelectList(db.Buildings, "BuildingID", "Name", room.BuildingID); ViewBag.AspNetRoles = db.AspNetRoles.ToList(); ViewBag.Assets = db.Assets.ToList(); return(View(room)); } catch (Exception ex) { ViewBag.Log = LogHandler.Helpers.LogHandler.HandleLog(LogHandler.Helpers.LogType.Warning, "Rooms/EditPOST", ex.Message, (ex.InnerException != null ? ex.InnerException.Message : ""), Request.Params); return(View("Error")); } }
public void AddRoomRole(RoomRole roomRole) { var room = Rooms.FirstOrDefault(r => r.Id == roomRole.Room_Id); if (room != null) { lock (RoomRoles) { if (RoomRoles.FirstOrDefault(rr => rr.Room_Id == roomRole.Room_Id && rr.User_Id == roomRole.User_Id && rr.Role_Id == roomRole.Role_Id) == null) { RoomRoles.Add(roomRole); lock (room.RoomRoles) { room.RoomRoles.Add(roomRole); } } } } }
public ChatGiftMessage(string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscribing, GiftType type, int amount, string message) : base(ChatEventType.GIFT, channel, messageId, user, roomRole, subscribing) { GiftType = type; GiftMessage = message; AmountGifts = amount; switch (type) { case GiftType.LEMON: GiftValue = 1m; break; case GiftType.ICE_CREAM: GiftValue = 10m; break; case GiftType.DIAMOND: GiftValue = 100m; break; case GiftType.NINJAGHINI: GiftValue = 1000m; break; case GiftType.NINJET: GiftValue = 10000m; break; case GiftType.BTT: case GiftType.TRX: GiftValue = (decimal)amount / 1000000; break; default: break; } GiftLinoValue = GiftLemonValue = (int)GiftValue; }
/// <summary> /// Retrieve all of the parties with a given role. /// Modify the affiliations of persons in this list, then call ModifyRoles /// </summary> /// <param name="role">The role to search for</param> /// <param name="callback">A callback to receive the participant list</param> /// <param name="state">Caller state information</param> public void RetrieveListByRole(RoomRole role, RoomParticipantsEvent callback, object state) { if (callback == null) throw new ArgumentNullException("callback"); /* <iq from='[email protected]/globe' id='voice3' to='*****@*****.**' type='get'> <query xmlns='http://jabber.org/protocol/muc#admin'> <item role='participant'/> </query> </iq> */ RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document); iq.To = m_room; AdminQuery query = iq.Instruction; query.AddItem().Role = role; m_manager.BeginIQ(iq, new IqCB(GotList), new RetrieveParticipantsState(callback, state)); }
public bool Input(Presence stanza) { string canonFrom = stanza.From.ToString().ToLower(); //Handle error case if (stanza.Type == PresenceType.Error) { //Check if the error relates to a pending room join operation TaskCompletionSource <JoinRoomResult> pendingRoomJoin = null; if (m_pendingRoomJoins.TryGetValue(canonFrom, out pendingRoomJoin)) { pendingRoomJoin.SetException(Util.ExceptionFromError(stanza.Data["error"], "Failed to join room " + stanza.From.ToString())); m_pendingRoomJoins.TryRemove(canonFrom, out pendingRoomJoin); return(true); } //Check if the error relates to a pending room leave operation TaskCompletionSource <bool> pendingRoomLeave = null; if (m_pendingRoomLeaves.TryGetValue(canonFrom, out pendingRoomLeave)) { pendingRoomLeave.SetException(Util.ExceptionFromError(stanza.Data["error"], "Failed to leave room " + stanza.From.ToString())); m_pendingRoomLeaves.TryRemove(canonFrom, out pendingRoomLeave); return(true); } } //Handle success case var x = stanza.Data["x"]; if (x != null && x.NamespaceURI == "http://jabber.org/protocol/muc#user") { var itemNode = x["item"]; if (itemNode != null) { //See if the result relates to a pending room join operation TaskCompletionSource <JoinRoomResult> pendingRoomJoin = null; if (m_pendingRoomJoins.TryGetValue(canonFrom, out pendingRoomJoin)) { //Parse room affiliation and role RoomAffiliation affiliation = RoomAffiliation.None; if (itemNode.HasAttribute("affiliation")) { string a = itemNode.GetAttribute("affiliation"); Enum.TryParse <RoomAffiliation>(a, true, out affiliation); } RoomRole role = RoomRole.None; if (itemNode.HasAttribute("role")) { Enum.TryParse <RoomRole>(itemNode.GetAttribute("role"), true, out role); } var result = new JoinRoomResult() { Affiliation = affiliation, Role = role }; Exception createException = null; //For rooms that don't exist, the server will create a new room and respond with a role of "owner" if (affiliation == RoomAffiliation.Owner) { //Server should respond with status code 201 to indicate room created. Search for it... //N.B. Prosody doesn't seem to include this node and just auto creates a default room bool created = false; foreach (XmlNode node in x.ChildNodes) { if (node.Name == "status") { var code = node.Attributes["code"]; if (code != null && code.InnerText == "201") { created = true; break; } } } if (created) { //If the room was created, the server expects confirmation of room settings //Send off a request to accept default instant room settings Jid roomJid = new Jid(stanza.From.Domain, stanza.From.Node); var response = im.IqRequest(Core.IqType.Set, roomJid, im.Jid, Xml.Element("query", "http://jabber.org/protocol/muc#owner").Child(Xml.Element("x", "jabber:x:data").Attr("type", "submit"))); if (response.Type == Core.IqType.Error) { createException = Util.ExceptionFromError(response, "Failed to join room " + roomJid); } } } if (createException != null) { pendingRoomJoin.SetException(createException); } else { pendingRoomJoin.SetResult(result); } m_pendingRoomJoins.TryRemove(canonFrom, out pendingRoomJoin); return(true); } //See if the result relates to a pending room leave operation TaskCompletionSource <bool> pendingRoomLeave = null; if (m_pendingRoomLeaves.TryGetValue(canonFrom, out pendingRoomLeave)) { pendingRoomLeave.SetResult(true); m_pendingRoomLeaves.TryRemove(canonFrom, out pendingRoomLeave); return(true); } } } return(false); }
public void UpdateRoomRole(int userId, string token, RoomRole rr) { client.UpdateRoomRole(application_Id, userId, token, rr); }
public IHttpActionResult GameAgain([FromBody] ChangeSetting_Request RequestMod) { try { if (RequestMod == null) { throw new ArgumentException("非法访问"); } if (RequestMod.RoomId < 1) { throw new ArgumentException("非法访问"); } var roles = RequestMod.roles.Split(','); foreach (var role in roles) { var Irole = Convert.ToInt32(role); var rolename = Enum.GetName(typeof(Wwa.Enum.wolverole), Irole); if (string.IsNullOrEmpty(rolename)) { throw new ArgumentException("无此角色"); } } using (MysqlDbContext db = new MysqlDbContext()) { var room = db.Rooms.FirstOrDefault(t => t.RoomId == RequestMod.RoomId && t.IsQuit == false); if (room == null) { throw new ArgumentException("无此房间"); } room.PersonsNum = RequestMod.Pnum; var Vic = Enum.GetName(typeof(Wwa.Enum.Victory), RequestMod.Victory); if (string.IsNullOrEmpty(Vic)) { room.VictoryCondition = Wwa.Enum.Victory.屠边; } else { room.VictoryCondition = (Wwa.Enum.Victory)Enum.Parse(typeof(Wwa.Enum.Victory), Vic); } var rolearr = roles.OrderBy(t => Guid.NewGuid()).ToList(); var dic = new Dictionary <int, string>(); for (int iss = 1; iss <= rolearr.Count(); iss++) { var vl = Convert.ToInt32(rolearr[iss - 1]); var name = Enum.Parse(typeof(Wwa.Enum.wolverole), vl.ToString()); RoomRole rr = new RoomRole() { LocationId = iss, RoleEnum = (Wwa.Enum.wolverole)name, Rid = RequestMod.RoomId }; dic.Add(iss, name.ToString()); db.RoomRoles.Add(rr); } int i = db.SaveChanges(); if (i > 0) { CreateRoom_Ac_Response returndata = new CreateRoom_Ac_Response() { RoomID = RequestMod.RoomId, Pnum = RequestMod.Pnum, Victory = room.VictoryCondition }; returndata.positions = dic; return(Ok(new AjaxResult() { state = ResultType.success.ToString(), data = returndata })); } else { return(Ok(new AjaxResult() { state = ResultType.error.ToString(), message = "房间更新失败" })); } } } catch (MySqlException e) { LogFactory.GetLogger("").Error(Environment.NewLine + DateTime.Now + "ChangeSetting房间更新失败(数据库问题):" + e.Message); return(Ok(new AjaxResult() { state = ResultType.error.ToString(), message = "房间更新失败,请联系管理员" })); } catch (ArgumentException e) { return(Ok(new AjaxResult() { state = ResultType.error.ToString(), message = e.Message })); } catch (Exception e) { return(Ok(new AjaxResult() { state = ResultType.error.ToString(), message = "非法操作:" + e.Message })); } }
public UserChatMessage(ChatEventType eventType, string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscribing) : base(eventType, channel, messageId) { User = user; RoomRole = roomRole; Subscribing = subscribing; }
public ChatModStatusChangeMessage(string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscribing, ModeratorStatusChange change) : base(ChatEventType.MOD, channel, messageId, user, roomRole, subscribing) { StatusChange = change; }
public T GetEntity <T>(int[] ids) where T : ModelEntity { DSClient client = new DSClient(Models.Const.ApplicationId); int userId; string token; if (GetToken(out userId, out token)) { var t = typeof(T); if (t == typeof(Application)) { Application app = client.GetApplication(userId, token, ids[0]); return(app as T); } else if (t == typeof(Role)) { Role role = client.GetRole(userId, token, ids[0]); return(role as T); } else if (t == typeof(Image)) { Image image = client.GetImage(userId, token, ids[0]); return(image as T); } else if (t == typeof(Command)) { Command cmd = client.GetCommand(userId, token, ids[0]); return(cmd as T); } else if (t == typeof(RoleCommand)) { RoleCommand rc = client.GetRoleCommand(userId, token, ids[0]); return(rc as T); } else if (t == typeof(RoleCommandView)) { RoleCommandView rc = client.GetRoleCommandView(userId, token, ids[0]); return(rc as T); } else if (t == typeof(User)) { User user = client.GetUser(userId, token, ids[0]); return(user as T); } else if (t == typeof(UserApplicationInfo)) { UserApplicationInfo info = client.GetUserInfo(userId, token, ids[0], ids[1]); return(info as T); } else if (t == typeof(RoomGroup)) { RoomGroup roomGroup = client.GetRoomGroup(userId, token, ids[0]); return(roomGroup as T); } else if (t == typeof(Room)) { Room room = client.GetRoom(userId, token, ids[0]); return(room as T); } else if (t == typeof(RoomRole)) { RoomRole rRole = client.GetRoomRole(userId, token, ids[0], ids[1], ids[2]); return(rRole as T); } else if (t == typeof(GiftGroup)) { GiftGroup giftGroup = client.GetGiftGroup(userId, token, ids[0]); return(giftGroup as T); } else if (t == typeof(Gift)) { Gift gift = client.GetGift(userId, token, ids[0]); return(gift as T); } else if (t == typeof(BlockType)) { BlockType b = client.GetBlockType(userId, token, ids[0]); return(b as T); } else if (t == typeof(BlockList)) { BlockList b = client.GetBlockList(userId, token, ids[0]); return(b as T); } else if (t == typeof(RoomRole)) { RoomRole rr = client.GetRoomRole(userId, token, ids[0], ids[1], ids[2]); return(rr as T); } else if (t == typeof(RoomConfig)) { RoomConfig c = client.GetRoomConfig(userId, token, ids[0]); return(c as T); } } return(null); }
public ChatTextMessage(string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscribing, string content, long subStreak) : base(ChatEventType.MESSAGE, channel, messageId, user, roomRole, subscribing) { Content = content; SubStreak = subStreak; }
public ChatSubscriptionMessage(string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscription, int months) : base(ChatEventType.SUBSCRIPTION, channel, messageId, user, roomRole, subscription) { Months = months; }
/// <summary> /// Change the role of a user in the room, by nickname. Must be a moderator. /// </summary> /// <param name="nick">The nickname of the user to modify.</param> /// <param name="role">The new role</param> /// <param name="reason">The reason for the change</param> public void ChangeRole(string nick, RoomRole role, string reason) { if (m_state != STATE.running) throw new InvalidOperationException("Must be in running state to change role: " + m_state.ToString()); if (nick == null) throw new ArgumentNullException("nick"); if (role == RoomRole.UNSPECIFIED) throw new ArgumentNullException("role"); /* <iq from='[email protected]/pda' id='kick1' to='*****@*****.**' type='set'> <query xmlns='http://jabber.org/protocol/muc#admin'> <item nick='pistol' role='none'> <reason>Avaunt, you cullion!</reason> </item> </query> </iq> */ RoomAdminIQ iq = new RoomAdminIQ(m_manager.Stream.Document); iq.To = m_room; iq.Type = IQType.set; AdminQuery query = iq.Instruction; AdminItem item = query.AddItem(); item.Nick = nick; item.Role = role; item.Reason = reason; m_manager.BeginIQ(iq, null, null); }
public ChatEmoteMessage(string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscribing, string emote) : base(ChatEventType.EMOTE, channel, messageId, user, roomRole, subscribing) { Emote = emote; }
/// <summary> /// Get all of the participants that are in a given room role. /// </summary> /// <param name="role">The role to search for</param> /// <returns></returns> public RoomParticipant[] GetParticipantsByRole(RoomRole role) { ArrayList res = new ArrayList(m_hash.Count); foreach (RoomParticipant party in m_hash.Values) { if (party.Role == role) res.Add(party); } return (RoomParticipant[])res.ToArray(typeof(RoomParticipant)); }
public ChatClipMessage(string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscribing, Uri link) : base(ChatEventType.CLIP, channel, messageId, user, roomRole, subscribing) { ClipUri = link; }
public ChatModeChangeMessage(string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscribing, ChatMode mode) : base(ChatEventType.CHAT_MODE, channel, messageId, user, roomRole, subscribing) { NewMode = mode; }
public ChatHostMessage(string channel, string messageId, PublicUserData user, RoomRole roomRole, bool subscribing, int viewers) : base(ChatEventType.HOST, channel, messageId, user, roomRole, subscribing) { Viewers = viewers; }