public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (String.IsNullOrEmpty(callerContext.RoomName)) { throw new InvalidOperationException("This command cannot be invoked from the Lobby."); } string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName; if (String.IsNullOrEmpty(targetRoomName)) { throw new InvalidOperationException("Which room?"); } ChatRoom targetRoom = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false); // ensure the user could join the room if they wanted to callingUser.EnsureAllowed(targetRoom); if (String.IsNullOrEmpty(targetRoom.InviteCode)) { context.Service.SetInviteCode(callingUser, targetRoom, RandomUtils.NextInviteCode()); } ChatRoom callingRoom = context.Repository.GetRoomByName(callerContext.RoomName); context.NotificationService.PostNotification(callingRoom, callingUser, String.Format("Invite Code for {0}: {1}", targetRoomName, targetRoom.InviteCode)); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { if (String.IsNullOrEmpty(callerContext.RoomName)) { throw new HubException(LanguageResources.InvokeFromRoomRequired); } string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName; if (String.IsNullOrEmpty(targetRoomName)) { throw new HubException(LanguageResources.InviteCode_RoomRequired); } ChatRoom targetRoom = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false); // ensure the user could join the room if they wanted to callingUser.EnsureAllowed(targetRoom); if (String.IsNullOrEmpty(targetRoom.InviteCode)) { context.Service.SetInviteCode(callingUser, targetRoom, RandomUtils.NextInviteCode()); } ChatRoom callingRoom = context.Repository.GetRoomByName(callerContext.RoomName); context.NotificationService.PostNotification(callingRoom, callingUser, String.Format(LanguageResources.InviteCode_Success, targetRoomName, targetRoom.InviteCode)); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName; if (String.IsNullOrEmpty(targetRoomName) || targetRoomName.Equals("Lobby", StringComparison.InvariantCultureIgnoreCase)) { throw new InvalidOperationException("Which room?"); } ChatRoom room = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false); // ensure the user could join the room if they wanted to callingUser.EnsureAllowed(room); context.NotificationService.ListAllowedUsers(room); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { string targetRoomName = args.Length > 0 ? args[0] : callerContext.RoomName; if (String.IsNullOrEmpty(targetRoomName)) { throw new HubException(LanguageResources.Owners_RoomRequired); } ChatRoom room = context.Repository.VerifyRoom(targetRoomName, mustBeOpen: false); // ensure the user could join the room if they wanted to callingUser.EnsureAllowed(room); context.NotificationService.ListOwners(room); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { string roomName = args.Length > 0 ? args[0] : callerContext.RoomName; if (String.IsNullOrEmpty(roomName)) { throw new InvalidOperationException("Which room do you want to list the current users of?"); } ChatRoom room = context.Repository.VerifyRoom(roomName); // ensure the user could join the room if they wanted to callingUser.EnsureAllowed(room); var names = context.Repository.GetOnlineUsers(room).Select(s => s.Name); context.NotificationService.ListUsers(room, names); }
public override void Execute(CommandContext context, CallerContext callerContext, ChatUser callingUser, string[] args) { string roomName = args.Length > 0 ? args[0] : callerContext.RoomName; if (String.IsNullOrEmpty(roomName)) { throw new HubException(LanguageResources.List_RoomRequired); } ChatRoom room = context.Repository.VerifyRoom(roomName); // ensure the user could join the room if they wanted to callingUser.EnsureAllowed(room); var names = context.Repository.GetOnlineUsers(room).Select(s => s.Name); context.NotificationService.ListUsers(room, names); }