コード例 #1
0
ファイル: Session.cs プロジェクト: ap0llo/wolpertinger
        public Session(string target, IConnectionManager connectionManager)
        {
            this.connectionManager = connectionManager;

            this.Target = target;
            this.Name = target;

            this.connection = connectionManager.GetClientConnection(target);
            if (connection == null)
            {
                connection = connectionManager.AddClientConnection(target);
                connection.ConnectionReset += connection_ConnectionReset;
                connection.ConnectionTimedOut += connection_ConnectionTimedOut;
                connection.RemoteErrorOccurred += connection_RemoteErrorOccurred;
            }
            //authComponent = (AuthenticationComponent)connection.GetClientComponent(ComponentNamesExtended.Authentication);
            //clientInfoComponent = (ClientInfoClientComponent)connection.GetClientComponent(ComponentNamesExtended.ClientInfoProvider);
            //loggingConfigurator = (XmppLoggingConfiguratorComponent)connection.GetClientComponent(ComponentNamesExtended.XmppLoggingConfigurator);
            //fileShareComponent = (FileShareClientComponent)connection.GetClientComponent(ComponentNamesExtended.FileShare);

            authComponent = new AuthenticationComponent() { ClientConnection = connection };
            clientInfoComponent = new ClientInfoClientComponent() { ClientConnection = connection };
            loggingConfigurator = new XmppLoggingConfiguratorComponent() { ClientConnection = connection };
            fileShareComponent = new FileShareClientComponent() { ClientConnection = connection };

            //CommandInfo info = new CommandInfo();

            commands.Add("get-status", new CommandInfo() { ParameterCount = 0, CommandMethod = getStatusCommand, CheckConnection = false});
            commands.Add("connect", new CommandInfo() { ParameterCount = 0, CommandMethod = connectCommand, CheckConnection = false });
            commands.Add("disconnect", new CommandInfo() { ParameterCount = 0, CommandMethod = disconnectCommand });
            commands.Add("userauth", new CommandInfo() { ParameterCount = 1, CommandMethod = userauthCommand });
            commands.Add("get-info", new CommandInfo() { ParameterCount = 0, CommandMethod = getInfoCommand });
            commands.Add("exit-session", new CommandInfo() { CheckConnection=false, ParameterCount = 0, CommandMethod = exitSessionCommand });

            commands.Add("logger.get-enabled", new CommandInfo() { ParameterCount = 0, CommandMethod = loggerGetEnabledCommand });
            commands.Add("logger.set-enabled", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerSetEnabledCommand });
            commands.Add("logger.get-loglevel", new CommandInfo() { ParameterCount = 0, CommandMethod = loggerGetLogLevelCommand });
            commands.Add("logger.set-loglevel", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerSetLogLevelCommand });
            commands.Add("logger.get-recipient", new CommandInfo() { ParameterCount = 0, CommandMethod = loggerGetRecipientCommand });
            commands.Add("logger.set-recipient", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerSetRecipientCommand });
            commands.Add("logger.get-debuglogging", new CommandInfo() { ParameterCount = 0, CommandMethod = loggerGetDebugLoggingCommand });
            commands.Add("logger.set-debuglogging", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerSetDebugLoggingCommand });
            commands.Add("logger.test-logging", new CommandInfo() { ParameterCount = 1, CommandMethod = loggerTestLoggingCommand });

            commands.Add("fileshare.add-directory", new CommandInfo() { ParameterCount = 2, CommandMethod = fileshareAddDirectoryCommand });
            commands.Add("fileshare.remove-directory", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareRemoveDirectoryCommand });
            commands.Add("fileshare.get-directory", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareGetDirectoryCommand });
            commands.Add("fileshare.get-file", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareGetFileCommand });
            commands.Add("fileshare.add-permission", new CommandInfo() { ParameterCount = -2, CommandMethod = fileshareAddPermissionCommand });
            commands.Add("fileshare.remove-permission", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareRemovePermissionCommand });
            commands.Add("fileshare.get-mounts", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareGetMountsCommand });
            commands.Add("fileshare.check-permission", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareCheckPermissionCommand });
            commands.Add("fileshare.get-permissions", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareGetPermissionsCommand });
            commands.Add("fileshare.get-rootdirectory", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareGetRootDirectoryCommand });
            commands.Add("fileshare.set-rootdirectory", new CommandInfo() { ParameterCount = 1, CommandMethod = fileshareSetRootDirectoryCommand });

            commands.Add("fileshare.create-snapshot", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareCreateSnapshotCommand });
            commands.Add("fileshare.get-snapshots", new CommandInfo() { ParameterCount = 0, CommandMethod = fileshareGetSnapshotsCommand });
        }
コード例 #2
0
        public Session(string target, IConnectionManager connectionManager)
        {
            this.connectionManager = connectionManager;

            this.Target = target;
            this.Name   = target;

            this.connection = connectionManager.GetClientConnection(target);
            if (connection == null)
            {
                connection = connectionManager.AddClientConnection(target);
                connection.ConnectionReset     += connection_ConnectionReset;
                connection.ConnectionTimedOut  += connection_ConnectionTimedOut;
                connection.RemoteErrorOccurred += connection_RemoteErrorOccurred;
            }
            //authComponent = (AuthenticationComponent)connection.GetClientComponent(ComponentNamesExtended.Authentication);
            //clientInfoComponent = (ClientInfoClientComponent)connection.GetClientComponent(ComponentNamesExtended.ClientInfoProvider);
            //loggingConfigurator = (XmppLoggingConfiguratorComponent)connection.GetClientComponent(ComponentNamesExtended.XmppLoggingConfigurator);
            //fileShareComponent = (FileShareClientComponent)connection.GetClientComponent(ComponentNamesExtended.FileShare);

            authComponent = new AuthenticationComponent()
            {
                ClientConnection = connection
            };
            clientInfoComponent = new ClientInfoClientComponent()
            {
                ClientConnection = connection
            };
            loggingConfigurator = new XmppLoggingConfiguratorComponent()
            {
                ClientConnection = connection
            };
            fileShareComponent = new FileShareClientComponent()
            {
                ClientConnection = connection
            };


            //CommandInfo info = new CommandInfo();

            commands.Add("get-status", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = getStatusCommand, CheckConnection = false
            });
            commands.Add("connect", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = connectCommand, CheckConnection = false
            });
            commands.Add("disconnect", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = disconnectCommand
            });
            commands.Add("userauth", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = userauthCommand
            });
            commands.Add("get-info", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = getInfoCommand
            });
            commands.Add("exit-session", new CommandInfo()
            {
                CheckConnection = false, ParameterCount = 0, CommandMethod = exitSessionCommand
            });


            commands.Add("logger.get-enabled", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = loggerGetEnabledCommand
            });
            commands.Add("logger.set-enabled", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = loggerSetEnabledCommand
            });
            commands.Add("logger.get-loglevel", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = loggerGetLogLevelCommand
            });
            commands.Add("logger.set-loglevel", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = loggerSetLogLevelCommand
            });
            commands.Add("logger.get-recipient", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = loggerGetRecipientCommand
            });
            commands.Add("logger.set-recipient", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = loggerSetRecipientCommand
            });
            commands.Add("logger.get-debuglogging", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = loggerGetDebugLoggingCommand
            });
            commands.Add("logger.set-debuglogging", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = loggerSetDebugLoggingCommand
            });
            commands.Add("logger.test-logging", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = loggerTestLoggingCommand
            });

            commands.Add("fileshare.add-directory", new CommandInfo()
            {
                ParameterCount = 2, CommandMethod = fileshareAddDirectoryCommand
            });
            commands.Add("fileshare.remove-directory", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = fileshareRemoveDirectoryCommand
            });
            commands.Add("fileshare.get-directory", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = fileshareGetDirectoryCommand
            });
            commands.Add("fileshare.get-file", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = fileshareGetFileCommand
            });
            commands.Add("fileshare.add-permission", new CommandInfo()
            {
                ParameterCount = -2, CommandMethod = fileshareAddPermissionCommand
            });
            commands.Add("fileshare.remove-permission", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = fileshareRemovePermissionCommand
            });
            commands.Add("fileshare.get-mounts", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = fileshareGetMountsCommand
            });
            commands.Add("fileshare.check-permission", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = fileshareCheckPermissionCommand
            });
            commands.Add("fileshare.get-permissions", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = fileshareGetPermissionsCommand
            });
            commands.Add("fileshare.get-rootdirectory", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = fileshareGetRootDirectoryCommand
            });
            commands.Add("fileshare.set-rootdirectory", new CommandInfo()
            {
                ParameterCount = 1, CommandMethod = fileshareSetRootDirectoryCommand
            });

            commands.Add("fileshare.create-snapshot", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = fileshareCreateSnapshotCommand
            });
            commands.Add("fileshare.get-snapshots", new CommandInfo()
            {
                ParameterCount = 0, CommandMethod = fileshareGetSnapshotsCommand
            });
        }