コード例 #1
0
        public void execute(TransferProtocol tp)
        {
            List <OnlineServer> oss = LitJson.JsonMapper.ToObject <List <OnlineServer> >(tp.message);

            if (oss != null)
            {
                Server.UpdateServers(oss);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the HttpServerTransport class.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="listenPort">The listen port.</param>
        /// <param name="resource">The resource.</param>
        public HttpServerTransport(
            TransferProtocol transferProtocol,
            int listenPort,
            string resource)
        {
            this.httpListener = new HttpListener();

            this.httpListener.Prefixes.Add(
                this.GetListenPrefix(transferProtocol, listenPort, resource));
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the PCHCServer class
        /// with the specified osted Cache Mode Listen Port and IPAddress type.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="hostedCacheModeListenPort">
        /// The specified BranchCache service's listen port in hosted cache mode.
        /// </param>
        /// <param name="ipaddressType">The IP address type.</param>
        public PCHCServer(TransferProtocol transferProtocol, int hostedCacheModeListenPort, IPAddressType ipaddressType)
        {
            this.httpServerTransport = new HttpServerTransport(
                transferProtocol,
                hostedCacheModeListenPort,
                ipaddressType,
                PCHCRESOURCE);

            this.httpServerTransport.HttpRequestEventHandle += new EventHandler <HttpRequestEventArg>(this.ReceiveHttpRequest);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the PCHCClient class 
        /// With the specified http transport type, server name, linsten port number and resource.
        /// </summary>
        /// <param name="httpTransportType">Http transport type.</param>
        /// <param name="serverName">The server name.</param>
        /// <param name="port">The listening port.</param>
        /// <param name="resource">The resource.</param>
        /// <param name="domainName">The domain name.</param>
        /// <param name="userName">The user name.</param>
        /// <param name="userPassword">The password.</param>
        public PCHCClient(TransferProtocol httpTransportType, string serverName, int port, string resource, string domainName, string userName, string userPassword)
        {
            if (httpTransportType != TransferProtocol.HTTP && httpTransportType != TransferProtocol.HTTPS)
            {
                throw new ArgumentException(
                    "httpTransportType contains invalid not supported transport type", "httpTransportType");
            }

            this.httpClientTransport = new HttpClientTransport(httpTransportType, serverName, port, resource, domainName, userName, userPassword);
        }
コード例 #5
0
 public FileTransferObject(string name, TransferProtocol protocol, string host, string username, string pass, int port, string rootDirectory = null)
 {
     _name     = name;
     _protocol = protocol;
     _host     = host;
     _user     = username;
     _pass     = pass;
     _port     = port;
     _rootDir  = rootDirectory;
 }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the PCHCClient class
        /// With the specified http transport type, server name, linsten port number and resource.
        /// </summary>
        /// <param name="httpTransportType">Http transport type.</param>
        /// <param name="serverName">The server name.</param>
        /// <param name="port">The listening port.</param>
        /// <param name="resource">The resource.</param>
        /// <param name="domainName">The domain name.</param>
        /// <param name="userName">The user name.</param>
        /// <param name="userPassword">The password.</param>
        public PCHCClient(TransferProtocol httpTransportType, string serverName, int port, string resource, string domainName, string userName, string userPassword)
        {
            if (httpTransportType != TransferProtocol.HTTP && httpTransportType != TransferProtocol.HTTPS)
            {
                throw new ArgumentException(
                          "httpTransportType contains invalid not supported transport type", "httpTransportType");
            }

            this.httpClientTransport = new HttpClientTransport(httpTransportType, serverName, port, resource, domainName, userName, userPassword);
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the HttpServerTransport class.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="listenPort">The listen port.</param>
        /// <param name="resource">The resource.</param>
        public HttpServerTransport(
            TransferProtocol transferProtocol,
            int listenPort,
            string resource)
        {
            this.httpListener = new HttpListener();

            this.httpListener.Prefixes.Add(
                this.GetListenPrefix(transferProtocol, listenPort, resource));
        }
コード例 #8
0
        /// <summary>
        /// Initialize the frame work adapter
        /// </summary>
        /// <param name="testSite">The test site instance associated with the current adapter.</param>
        public override void Initialize(ITestSite testSite)
        {
            base.Initialize(testSite);
            this.pccrtpStackClient = new PccrtpClient();

            TransferProtocol transpotType = TransferProtocol.HTTPS;

            string hostedCacheMachineName = Site.Properties.Get("Environment.HostedCacheServer.MachineName");

            this.pchcClient =
                new PCHCClient(transpotType, hostedCacheMachineName, PCHCPROTOCOLPORT, PCHCRESOURCE);
        }
コード例 #9
0
        }/*End of RemoveFile method*/

        public IProcessResult FileExists(TransferProtocol protocol,
                                         ITransmissionDetails transmissionDetails)
        {
            switch (protocol)
            {
            case TransferProtocol.Sftp:
            case TransferProtocol.Ftp:
                return(FileExistsFileTransfer(protocol, transmissionDetails));

            default:
                throw new System.ArgumentException($"Invalid Transfer Protocol: {protocol}");
            }
        }/*End of FileExists method*/
コード例 #10
0
        public static IMessage CreateMessage(this TransferProtocol protocol, IMessageProducer messageProducer, object msg)
        {
            switch (protocol)
            {
            case TransferProtocol.Binary:
                return(messageProducer.CreateObjectMessage(msg));

            case TransferProtocol.Json:
                return(messageProducer.CreateTextMessage(msg is string s ? s : JsonConvert.SerializeObject(msg)));

            default:
                throw new NotSupportedException($"{typeof(TransferProtocol).FullName}.{protocol.ToString()}");
            }
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the HttpClientTransport class.
        /// Constructor of class HttpClientTransport to generate HTTP or HTTPs URI.
        /// </summary>
        /// <param name="transfer">Indicates the transfer protocol is HTTP or HTTPs.</param>
        /// <param name="serverAddress">The address of HTTP server.</param>
        /// <param name="port">The port number of HTTP server.</param>
        /// <param name="fileName">The requested file name.</param>
        /// <param name="logger">An instance of ILogPrinter.</param>
        public HttpClientTransport(
            TransferProtocol transfer,
            string serverAddress,
            int port,
            string fileName,
            ILogPrinter logger) :
            this(transfer, serverAddress, port, fileName, null, null, null)
        {
            if (null == logger)
            {
                throw new ArgumentNullException("logger", "The input parameter \"logger\" is null.");
            }

            this.logger = logger;
            this.logger.AddInfo("The HTTP client transport is created successfully.");
        }
コード例 #12
0
        }/*End of RemoveFileTransfer method*/

        private IProcessResult FileExistsFileTransfer(
            TransferProtocol protocol,
            ITransmissionDetails transmissionDetails)
        {
            TransferProtocolProcessState StateCheck(bool p) => p
                ? TransferProtocolProcessState.Success
                : TransferProtocolProcessState.CheckExistsFailed;

            var fileProtocolWorker
                = GetTransferService(protocol, transmissionDetails);

            return(fileProtocolWorker.CheckIfFileExists(
                       transmissionDetails.FileIoDetails.DirectoryName,
                       transmissionDetails.FileIoDetails.FileName,
                       StateCheck));
        }/*End of FileExistsFileTransfer method*/
コード例 #13
0
        /// <summary>
        /// Initializes a new instance of the HttpClientTransport class.
        /// Constructor of class HttpClientTransport to generate HTTP or HTTPs URI.
        /// </summary>
        /// <param name="transfer">Indicates the transfer protocol is HTTP or HTTPs.</param>
        /// <param name="serverAddress">The address of HTTP server.</param>
        /// <param name="port">The port number of HTTP server.</param>
        /// <param name="fileName">The requested file name.</param>
        /// <param name="logger">An instance of ILogPrinter.</param>
        public HttpClientTransport(
            TransferProtocol transfer,
            string serverAddress,
            int port,
            string fileName,
            ILogPrinter logger)
            : this(transfer, serverAddress, port, fileName, null, null, null)
        {
            if (null == logger)
            {
                throw new ArgumentNullException("logger", "The input parameter \"logger\" is null.");
            }

            this.logger = logger;
            this.logger.AddInfo("The HTTP client transport is created successfully.");
        }
コード例 #14
0
        /// <summary>
        /// Initializes a new instance of the PCHCClient class
        /// With the specified http transport type, server name, linsten port number and resource.
        /// </summary>
        /// <param name="httpTransportType">Http transport type.</param>
        /// <param name="serverName">The server name.</param>
        /// <param name="port">The listening port.</param>
        /// <param name="resource">The resource.</param>
        /// <param name="logger">The logger.</param>
        public PCHCClient(TransferProtocol httpTransportType, string serverName, int port, string resource, ILogPrinter logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger", "The input parameter \"logger\" is null.");
            }

            this.logger = logger;

            if (httpTransportType != TransferProtocol.HTTP && httpTransportType != TransferProtocol.HTTPS)
            {
                throw new ArgumentException(
                          "httpTransportType contains invalid not supported transport type", "httpTransportType");
            }

            this.httpClientTransport = new HttpClientTransport(httpTransportType, serverName, port, resource, logger);
        }
コード例 #15
0
        }/*End of ListFiles method*/

        private IProcessResult DownloadFileViaFileTransfer(
            TransferProtocol protocol,
            ITransmissionDetails transmissionDetails)
        {
            TransferProtocolProcessState StateCheck(bool p) => p
                ? TransferProtocolProcessState.Success
                : TransferProtocolProcessState.DownloadFailed;

            var fileProtocolWorker
                = GetTransferService(protocol, transmissionDetails);

            return(fileProtocolWorker.DownloadFile(
                       transmissionDetails.TransferDetails.SourceDirectory,
                       transmissionDetails.TransferDetails.SourceFileName,
                       transmissionDetails.TransferDetails.DestinationDirectory,
                       transmissionDetails.TransferDetails.DestinationFileName,
                       StateCheck,
                       transmissionDetails.TransferDetails.OverrideExisting));
        }/*End of DownloadFileViaFileTransfer method*/
コード例 #16
0
        /// <summary>
        /// Initialize pchc client.
        /// </summary>
        /// <param name="testSite">The test site instance associated with the current adapter.</param>
        public void InitializePchcClient(ITestSite testSite)
        {
            if (this.GetProperty("PCHC.TransportType").ToLower() == "Https".ToLower())
            {
                this.transportType = TransferProtocol.HTTPS;
            }
            else if (this.GetProperty("PCHC.TransportType").ToLower() == "Http".ToLower())
            {
                this.transportType = TransferProtocol.HTTP;
            }

            this.httpsListenPort        = PCHCPROTOCOLPORT;
            this.hostedCacheMachineName = this.GetProperty("Environment.HostedCacheServer.MachineName");

            this.pchcClient = new PCHCClient(
                this.transportType,
                this.hostedCacheMachineName,
                this.httpsListenPort,
                PCHCRESOURCE,
                new Logger(testSite));
        }
コード例 #17
0
        public static void sendMessage(TransferProtocol tp)
        {
            String message = LitJson.JsonMapper.ToJson(tp);

            if (writer != null)
            {
                try
                {
                    message = AESCryptos.AESEncrypt(message, SERVER_AES_KEY);

                    writer.WriteLine(message);

                    writer.Flush();

                    stream.Flush();
                }
                catch
                {
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Initialize pchc client.
        /// </summary>
        /// <param name="testSite">The test site instance associated with the current adapter.</param>
        public void InitializePchcClient(ITestSite testSite)
        {
            if (this.GetProperty("PCHC.TransportType").ToLower() == "Https".ToLower())
            {
                this.transportType = TransferProtocol.HTTPS;
            }
            else if (this.GetProperty("PCHC.TransportType").ToLower() == "Http".ToLower())
            {
                this.transportType = TransferProtocol.HTTP;
            }

            this.httpsListenPort = PCHCPROTOCOLPORT;
            this.hostedCacheMachineName = this.GetProperty("Environment.HostedCacheServer.MachineName");

            this.pchcClient = new PCHCClient(
                this.transportType,
                this.hostedCacheMachineName,
                this.httpsListenPort,
                PCHCRESOURCE,
                new Logger(testSite));
        }
コード例 #19
0
        }/*End of FileExistsFileTransfer method*/

        private IProcessResult <IEnumerable <string> > ListFilesFileTransfer(
            TransferProtocol protocol,
            ITransmissionDetails transmissionDetails)
        {
            TransferProtocolProcessState StateCheck(bool p) => p
                ? TransferProtocolProcessState.Success
                : TransferProtocolProcessState.ListDirectoryFailed;

            var fileProtocolWorker
                = GetTransferService(protocol, transmissionDetails);
            var result = fileProtocolWorker.ListDirectoryContent(
                transmissionDetails.FileIoDetails.DirectoryName,
                StateCheck, file => true,
                transmissionDetails.ConnectionDetails.DisconnectOnComplete);

            return(new ProcessResult <IEnumerable <string> >
            {
                ProcessCompletionState = result.ProcessCompletionState,
                ProcessResultException = result.ProcessResultException,
                ProcessResultMessage = result.ProcessResultMessage,
                ProcessResultValue = result.ProcessResultValue
            });
        } /*End of ListFilesFileTransfer method*/
コード例 #20
0
        public static T Get <T>(this TransferProtocol protocol, IMessage msg) where T : class
        {
            switch (protocol)
            {
            case TransferProtocol.Binary:
                if (msg is IObjectMessage obj)
                {
                    return(obj.Body as T);
                }
                break;

            case TransferProtocol.Json:
                if (msg is ITextMessage text)
                {
                    return(typeof(T) == typeof(string) ? text.Text as T : JsonConvert.DeserializeObject <T>(text.Text));
                }
                break;

            default:
                throw new NotSupportedException($"{typeof(TransferProtocol).FullName}.{protocol.ToString()}");
            }

            return(default);
コード例 #21
0
    public string getConnectionAdjusted(TransferProtocol tp)
    {
        string connectionAdjusted = "";

        switch (tp.connectionType)
        {
        case TransferProtocol.ConnectionType.Receive:
            connectionAdjusted = tp.receiveIP + ":" + tp.receivePort + "<-";
            break;

        case TransferProtocol.ConnectionType.ReceiveAndSend:
            connectionAdjusted = tp.receiveIP + ":" + tp.receivePort + "<->" + tp.destinationIP + ":" + tp.destinationPort;
            break;

        case TransferProtocol.ConnectionType.Send:
            connectionAdjusted = "->" + tp.destinationIP + ":" + tp.destinationPort;
            break;

        default:
            connectionAdjusted = "Error in connection";
            break;
        }
        return(connectionAdjusted);
    }
コード例 #22
0
        /// <summary>
        /// Get the listen prefix.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="ipaddressType">The ip address type.</param>
        /// <param name="hostedCacheModeListenPort">The hosted cache mode listen port.</param>
        /// <param name="resource">The customer resource data.</param>
        /// <returns>The listen prefix string.</returns>
        private string GetListenPrefix(
            TransferProtocol transferProtocol,
            int hostedCacheModeListenPort,
            string resource)
        {
            string transportTypeStr;
            string listenPrefix = null;

            if (resource == null)
            {
                resource = string.Empty;
            }
            else if (!resource.EndsWith("/") && resource != string.Empty)
            {
                resource = resource + "/";
            }

            if (transferProtocol == TransferProtocol.HTTPS)
            {
                transportTypeStr = "https";
            }
            else if (transferProtocol == TransferProtocol.HTTP)
            {
                transportTypeStr = "http";
            }
            else
            {
                throw new ArgumentException("The supported transport type in pchc is http or https for this version.", "transportType");
            }

            listenPrefix =
                transportTypeStr + "://+:"
                + hostedCacheModeListenPort + "/" + resource;

            return(listenPrefix);
        }
コード例 #23
0
        /// <summary>
        /// Initializes a new instance of the HttpServerTransport class.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="listenPort">The listen port.</param>
        /// <param name="ipaddressType">The IP address type.</param>
        /// <param name="resource">The resource.</param>
        /// <param name="logger">The logger.</param>
        public HttpServerTransport(
            TransferProtocol transferProtocol,
            int listenPort,
            IPAddressType ipaddressType,
            string resource,
            ILogPrinter logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger", "The input parameter \"logger\" is null.");
            }

            this.logger = logger;

            this.httpListener = new HttpListener();

            string prefix = this.GetListenPrefix(transferProtocol, listenPort, resource);

            this.httpListener.Prefixes.Add(prefix);

            this.logger.AddDebug(string.Format(
                                     "Initialize the http server transport and add prefix: {0} to http listener.",
                                     prefix));
        }
コード例 #24
0
        /// <summary>
        /// Initializes a new instance of the PCHCServer class 
        /// with the specified osted Cache Mode Listen Port and IPAddress type.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="hostedCacheModeListenPort">
        /// The specified BranchCache service's listen port in hosted cache mode.
        /// </param>
        /// <param name="ipaddressType">The IP address type.</param>
        /// <param name="logger">The logger.</param>
        public PCHCServer(
            TransferProtocol transferProtocol,
            int hostedCacheModeListenPort,
            IPAddressType ipaddressType,
            ILogPrinter logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger", "The input parameter \"logger\" is null.");
            }

            this.logger = logger;

            this.httpServerTransport = new HttpServerTransport(
                transferProtocol,
                hostedCacheModeListenPort,
                ipaddressType,
                PCHCRESOURCE,
                logger);

            this.httpServerTransport.HttpRequestEventHandle
                += new EventHandler<HttpRequestEventArg>(this.ReceiveHttpRequest);

            this.logger.AddDebug(@"Register the delegate EventHandle with generic parameter HttpRequestEverntArg
                and the handle method is ReceiveHttpRequest.");
        }
コード例 #25
0
        /// <summary>
        /// Initializes a new instance of the PCHCServer class 
        /// with the specified osted Cache Mode Listen Port and IPAddress type.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="hostedCacheModeListenPort">
        /// The specified BranchCache service's listen port in hosted cache mode.
        /// </param>
        /// <param name="ipaddressType">The IP address type.</param>
        public PCHCServer(TransferProtocol transferProtocol, int hostedCacheModeListenPort, IPAddressType ipaddressType)
        {
            this.httpServerTransport = new HttpServerTransport(
                transferProtocol,
                hostedCacheModeListenPort,
                ipaddressType,
                PCHCRESOURCE);

            this.httpServerTransport.HttpRequestEventHandle += new EventHandler<HttpRequestEventArg>(this.ReceiveHttpRequest);
        }
コード例 #26
0
        /// <summary>
        /// Initializes a new instance of the PCHCClient class 
        /// With the specified http transport type, server name, linsten port number and resource.
        /// </summary>
        /// <param name="httpTransportType">Http transport type.</param>
        /// <param name="serverName">The server name.</param>
        /// <param name="port">The listening port.</param>
        /// <param name="resource">The resource.</param>
        /// <param name="logger">The logger.</param>
        public PCHCClient(TransferProtocol httpTransportType, string serverName, int port, string resource, ILogPrinter logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger", "The input parameter \"logger\" is null.");
            }

            this.logger = logger;

            if (httpTransportType != TransferProtocol.HTTP && httpTransportType != TransferProtocol.HTTPS)
            {
                throw new ArgumentException(
                    "httpTransportType contains invalid not supported transport type", "httpTransportType");
            }

            this.httpClientTransport = new HttpClientTransport(httpTransportType, serverName, port, resource, logger);
        }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the PCHCClient class 
 /// With the specified http transport type, server name, linsten port number and resource.
 /// </summary>
 /// <param name="httpTransportType">Http transport type.</param>
 /// <param name="serverName">The server name.</param>
 /// <param name="port">The listening port.</param>
 /// <param name="resource">The resource.</param>
 public PCHCClient(TransferProtocol httpTransportType, string serverName, int port, string resource)
     : this(httpTransportType, serverName, port, resource, null, null, null)
 {
 }
コード例 #28
0
 /// <summary>
 /// Initializes a new instance of the PCHCClient class
 /// With the specified http transport type, server name, linsten port number and resource.
 /// </summary>
 /// <param name="httpTransportType">Http transport type.</param>
 /// <param name="serverName">The server name.</param>
 /// <param name="port">The listening port.</param>
 /// <param name="resource">The resource.</param>
 public PCHCClient(TransferProtocol httpTransportType, string serverName, int port, string resource)
     : this(httpTransportType, serverName, port, resource, null, null, null)
 {
 }
コード例 #29
0
 /// <summary>
 /// Initializes a new instance of the HttpClientTransport class.
 /// Constructor of class HttpClientTransport to generate HTTP or HTTPs URI.
 /// </summary>
 /// <param name="transfer">Indicates the transfer protocol is HTTP or HTTPs.</param>
 /// <param name="serverAddress">The address of HTTP server.</param>
 /// <param name="port">The port number of HTTP server.</param>
 /// <param name="fileName">The requested file name.</param>
 public HttpClientTransport(TransferProtocol transfer, string serverAddress, int port, string fileName)
     : this(transfer, serverAddress, port, fileName, null, null, null)
 {
 }
コード例 #30
0
        /// <summary>
        /// Initializes a new instance of the HttpServerTransport class.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="listenPort">The listen port.</param>
        /// <param name="ipaddressType">The IP address type.</param>
        /// <param name="resource">The resource.</param>
        /// <param name="logger">The logger.</param>
        public HttpServerTransport(
            TransferProtocol transferProtocol,
            int listenPort,
            IPAddressType ipaddressType,
            string resource,
            ILogPrinter logger)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger", "The input parameter \"logger\" is null.");
            }

            this.logger = logger;

            this.httpListener = new HttpListener();

            string prefix = this.GetListenPrefix(transferProtocol, listenPort, resource);

            this.httpListener.Prefixes.Add(prefix);

            this.logger.AddDebug(string.Format(
                "Initialize the http server transport and add prefix: {0} to http listener.",
                prefix));
        }
コード例 #31
0
        public static void connectionServer()
        {
            log("初始化连接集群服务器完成,获取认证服务器线程开启...", Constant.info, Constant.infoColor);
            while (runing)
            {
                String message = null;

                try
                {
                    message = reader.ReadLine();
                }
                catch (System.Exception ex)
                {
                    //Close();
                    break;
                }
                if (message == null)
                {
                    // Close();
                    break;
                }

                if (message.Length < 3)
                {
                    continue;
                }

                log(message, Constant.info, Constant.infoColor);

                if (SERVER_AES_KEY != null)
                {
                    message = AESCryptos.Decrypt(message, SERVER_AES_KEY);
                }

                //log(SERVER_AES_KEY, Constant.info, Constant.infoColor);

                log(message, Constant.info, Constant.infoColor);
                TransferProtocol tp = null;
                try
                {
                    tp = LitJson.JsonMapper.ToObject <TransferProtocol>(message);
                }
                catch (LitJson.JsonException)
                {
                }
                if (tp == null)
                {
                    continue;
                }
                String code = tp.protocolCode;
                if (code == null || "".Equals(code))
                {
                    continue;
                }
                if (SERVER_RESPONSED.ContainsKey(code))
                {
                    OperatorHandler handler = (OperatorHandler)SERVER_RESPONSED[code];
                    handler.execute(tp);
                }
            }
        }
コード例 #32
0
 /// <summary>
 /// Initializes a new instance of the HttpClientTransport class.
 /// Constructor of class HttpClientTransport to generate HTTP or HTTPs URI.
 /// </summary>
 /// <param name="transfer">Indicates the transfer protocol is HTTP or HTTPs.</param>
 /// <param name="serverAddress">The address of HTTP server.</param>
 /// <param name="port">The port number of HTTP server.</param>
 /// <param name="fileName">The requested file name.</param>
 public HttpClientTransport(TransferProtocol transfer, string serverAddress, int port, string fileName)
     : this(transfer, serverAddress, port, fileName, null, null, null)
 {
 }
コード例 #33
0
 public void AddOptionWithObject(TransferProtocol methodObject, Dropdown.OptionData od)
 {
     dropdownObjects.Add(methodObject);
     base.options.Add(od);
 }
コード例 #34
0
        /// <summary>
        /// Initializes a new instance of the HttpClientTransport class.
        /// Constructor of class HttpClientTransport to generate HTTP or HTTPs URI.
        /// </summary>
        /// <param name="transfer">Indicates the transfer protocol is HTTP or HTTPs.</param>
        /// <param name="serverAddress">The address of HTTP server.</param>
        /// <param name="port">The port number of HTTP server.</param>
        /// <param name="fileName">The requested file name.</param>
        /// <param name="domainName">The domain name.</param>
        /// <param name="userName">The user name.</param>
        /// <param name="userPassword">The password.</param>
        public HttpClientTransport(
            TransferProtocol transfer,
            string serverAddress,
            int port,
            string fileName,
            string domainName,
            string userName,
            string userPassword)
        {
            string uriString = string.Empty;
            switch (transfer)
            {
                case TransferProtocol.HTTP:
                    uriString = "http://";
                    break;
                case TransferProtocol.HTTPS:
                    uriString = "https://";
                    break;
                default:
                    break;
            }

            uriString = uriString + serverAddress + ":" + port.ToString() + "/" + fileName;
            this.httpUri = new Uri(uriString);
            this.domainName = domainName;
            this.userName = userName;
            this.userPassword = userPassword;
        }
コード例 #35
0
 public ConcreteTransferServiceFactory(
     TransferProtocol transferProtocol,
     IConnectionDetails connectionDetails)
     : base(transferProtocol, connectionDetails)
 {
 }
コード例 #36
0
 public Server(TransferProtocol transferprotocol, int port)
 {
     _protocolReceiver = transferprotocol.GetReceiverProtocol(HandleIncomingStream, port);
 }
コード例 #37
0
        /// <summary>
        /// Get the listen prefix.
        /// </summary>
        /// <param name="transferProtocol">The transport type will be used</param>
        /// <param name="ipaddressType">The ip address type.</param>
        /// <param name="hostedCacheModeListenPort">The hosted cache mode listen port.</param>
        /// <param name="resource">The customer resource data.</param>
        /// <returns>The listen prefix string.</returns>
        private string GetListenPrefix(
            TransferProtocol transferProtocol,
            int hostedCacheModeListenPort,
            string resource)
        {
            string transportTypeStr;
            string listenPrefix = null;

            if (resource == null)
            {
                resource = string.Empty;
            }
            else if (!resource.EndsWith("/") && resource != string.Empty)
            {
                resource = resource + "/";
            }

            if (transferProtocol == TransferProtocol.HTTPS)
            {
                transportTypeStr = "https";
            }
            else if (transferProtocol == TransferProtocol.HTTP)
            {
                transportTypeStr = "http";
            }
            else
            {
                throw new ArgumentException("The supported transport type in pchc is http or https for this version.", "transportType");
            }

            listenPrefix =
                        transportTypeStr + "://+:"
                        + hostedCacheModeListenPort + "/" + resource;

            return listenPrefix;
        }