예제 #1
0
        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);
        }
예제 #2
0
파일: IOnExHub.cs 프로젝트: stwehrli/IOnEx
 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);
 }
예제 #3
0
        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);
        }
예제 #4
0
 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;
 }
예제 #5
0
 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);
 }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
        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;
            }
        }
예제 #9
0
 public abstract void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args);
예제 #10
0
파일: IOnExHub.cs 프로젝트: stwehrli/IOnEx
        /// <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;
        }
예제 #11
0
파일: IOnExHub.cs 프로젝트: stwehrli/IOnEx
 void INotificationService.Test(Client client, string message)
 {
     Clients.Caller.addMessage("NotificationService: " + message);
 }
예제 #12
0
 public void Remove(Client client)
 {
     db.Clients.Remove(client);
     db.SaveChanges();
 }
예제 #13
0
 public void Add(Client client)
 {
     db.Clients.Add(client);
     db.SaveChanges();
 }
예제 #14
0
 public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args)
 {
     context.NotificationService.Test(callingClient, "This is just a test!");
 }