Example #1
0
        public async Task Handle(CommandRequest request)
        {
            OutputMode outputMode = CommandParser.ParseOutputMode(request.GetArg(1, "text"));

            if (outputMode == OutputMode.CSV)
            {
                await request.WriteLine("Id,Name,Remote Endpoint,Current Plane,Viewport");
            }

            foreach (NibriClient client in server.AppServer.NibriClients)
            {
                object[] lineParams = new object[] {
                    client.Id,
                    client.Name,
                    client.RemoteEndpoint,
                    client.CurrentPlane.Name,
                    client.CurrentViewPort
                };
                string outputLine = string.Format("{0}: {1} from {1}, on {3} looking at {4}", lineParams);

                if (outputMode == OutputMode.CSV)
                {
                    outputLine = string.Join(",", lineParams);
                }

                await request.WriteLine(outputLine);
            }
            await request.WriteLine();

            if (outputMode == OutputMode.Text)
            {
                await request.WriteLine($"Total {server.AppServer.ClientCount} clients");
            }
        }
Example #2
0
        public async Task ListUser(CommandRequest request)
        {
            string     username   = request.GetArg(2, "");
            OutputMode outputMode = CommandParser.ParseOutputMode(request.GetArg(3, "text"));

            if (username.Length == 0)
            {
                await request.WriteLine("Error: no username specified.");

                return;
            }

            // FUTURE: We need to be able to distinguish between viewing & editing here, amongst other places
            bool canViewAny            = server.AccountManager.GetByName(username).HasPermission(server.AccountManager.ResolvePermission("view-any-plane"));
            IEnumerable <Plane> planes = server.PlaneManager.Planes.Where((Plane nextPlane) => canViewAny || nextPlane.HasMember(username));

            if (outputMode == OutputMode.CSV)
            {
                await request.WriteLine("Plane Name,Role");
            }
            foreach (Plane nextPlane in planes)
            {
                object[] formatArgs = new object[] {
                    nextPlane.Name,
                    (nextPlane.HasCreator(username) || canViewAny ? "Creator" : "Member")
                };

                switch (outputMode)
                {
                case OutputMode.Text:
                    await request.WriteLine("{0} as {1}", formatArgs);

                    break;

                case OutputMode.CSV:
                    await request.WriteLine(string.Join(",", formatArgs.Select((object arg) => arg.ToString())));

                    break;
                }
            }

            //await request.Write(generatePlaneList(server.PlaneManager.Planes, outputMode));
        }
Example #3
0
 public async Task ListPerms(CommandRequest request)
 {
     foreach (RbacPermission perm in server.AccountManager.Permissions)
     {
         await request.WriteLine(
             request.GetArg(2, "text") == "csv"?
             $"{perm.Name},{perm.Description}" :
             $"{perm.Name}: {perm.Description}"
             );
     }
 }
Example #4
0
        public async Task Handle(CommandRequest request)
        {
            // Save the ripplespace
            CommandSave saver = new CommandSave();

            saver.Setup(server);

            await saver.Handle(request);

            // Stop the listeners
            server.AppServer.Stop(request.GetArg(1, "This server is shutting down."));
            server.PlaneManager.StopMaintenanceMonkey();
            server.CommandServer.Stop();

            await request.WriteLine("Stopping Nibriboard Server.");
        }
Example #5
0
        public async Task List(CommandRequest request)
        {
            OutputMode outputMode = CommandParser.ParseOutputMode(request.GetArg(2, "text"));

            await request.Write(generatePlaneList(server.PlaneManager.Planes, outputMode));
        }