public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { if (!callingClient.IsAdmin) { //throw new InvalidOperationException("You are not an admin."); } ExecuteAdminOperation(context, callerContext, callingClient, args); }
void INotificationService.Broadcast(Client client, string message) { // Tell all users in all rooms about this message //foreach (var room in db.Rooms) //{ // Clients.Group(room.Name).addMessage(message); //} Clients.All.addMessage("NotificationService: " + message); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { string messageText = String.Join(" ", args).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new InvalidOperationException("What did you want to broadcast?"); } context.NotificationService.Broadcast(callingClient, messageText); }
public DashboardClientView(Client client) { ClientId = client.ClientId; Name = client.Name; IsOnline = client.IsOnline; IsAdmin = client.IsAdmin; IsMonitor = client.IsMonitor; TimeLastActive = client.TimeLastActive.ToShortTimeString(); RoomName = "Entrace"; ConnectionCount = client.Connections.Count; }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { string message; try { string roleName = args[0]; string members = string.Join(",", System.Web.Security.Roles.GetUsersInRole(roleName)); message = "Users in role '" + roleName + "': " + members; } catch (Exception ex) { message = ex.ToString(); } context.NotificationService.Test(callingClient, message); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { string message; try { string username = args[0]; message = "Deleted user " + username; System.Web.Security.Membership.DeleteUser(username); } catch (Exception ex) { message = ex.ToString(); } context.NotificationService.Test(callingClient, message); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { string message; try { string username = args[0]; string roleName = args[1]; message = "Added user " + username + " to role " + roleName; System.Web.Security.Roles.AddUserToRole(username, roleName); } catch (Exception ex) { message = ex.ToString(); } context.NotificationService.Test(callingClient, message); }
public ClientView(Client client) { ClientId = client.ClientId; Name = client.Name; IsOnline = client.IsOnline; IsAdmin = client.IsAdmin; IsMonitor = client.IsMonitor; TimeCreated = client.TimeCreated.ToShortTimeString(); TimeLastActive = client.TimeLastActive.ToShortTimeString(); RoomName = "Entrace"; ConnectionCount = client.Connections.Count; var con = client.Connections.OrderByDescending(x => x.TimeCreated).FirstOrDefault(); if(con != null) { Ip = con.Ip; Browser = con.Browser; } }
public abstract void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args);
/// <summary> /// Called from client after connection is established /// </summary> /// <returns>True if join was successful</returns> public bool Join() { // Check the user id cookie Cookie clientIdCookie; if (!Context.RequestCookies.TryGetValue("IOnExId", out clientIdCookie)) { return false; } //Check the user Client client = db.GetClientById(clientIdCookie.Value); if (client == null) { client = new Client { ClientId = clientIdCookie.Value, Name = clientIdCookie.Value.Substring(0, 8), ConnectionId = Context.ConnectionId, IsAdmin = false, IsMonitor = false, IsOnline = true, TimeCreated = DateTime.Now, TimeLastActive = DateTime.Now }; db.Add(client); Clients.Caller.addMessage("Added Client: " + client.ClientId); client = db.GetClientById(clientIdCookie.Value); } else { client.IsOnline = true; client.ConnectionId = Context.ConnectionId; client.TimeLastActive = DateTime.Now; } //Check the connection Connection connection = db.GetConnectionById(Context.ConnectionId); if (connection == null) { // Get request object var request = Context.Request.GetHttpContext().Request; //Add a client connection = new Connection { ConnectionId = Context.ConnectionId, IsActive = true, TimeCreated = DateTime.Now, Ip = request.ServerVariables["REMOTE_ADDR"].ToString(), TimeLastActive = DateTime.UtcNow }; db.Add(connection); connection = db.GetConnectionById(Context.ConnectionId); //Clients.Caller.addMessage("Added connection: " + Context.ConnectionId); } // Check room Room room = db.GetRoomByName("Entrance"); if (room == null) { room = new Room { Name = "Entrance" }; db.Add(room); db.CommitChanges(); room = db.GetRoomByName("Entrance"); } // Add user, room, group, and connection var roomUser = room.Clients.FirstOrDefault(r => r.ClientId == client.ClientId); if (roomUser == null) { room.Clients.Add(client); } Groups.Add(Context.ConnectionId, "Entrance"); //Join the two client.Connections.Add(connection); connection.Client = client; db.CommitChanges(); // Notify group members UpdateUserList(); Clients.Caller.addMessage(Short(Context.ConnectionId) + " has joined."); return true; }
void INotificationService.Test(Client client, string message) { Clients.Caller.addMessage("NotificationService: " + message); }
public void Remove(Client client) { db.Clients.Remove(client); db.SaveChanges(); }
public void Add(Client client) { db.Clients.Add(client); db.SaveChanges(); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { context.NotificationService.Test(callingClient, "This is just a test!"); }