Пример #1
0
        public void Open(int port)
        {
            if (port < 0 || port > 65536)
            {
                throw new ArgumentOutOfRangeException("port", "port value is invalid");
            }

            string urlService = "net.pipe://localhost/" + SERVICE_NAME + "_" + port.ToString();

            lock (mClientLocker)
            {
                if (mProxy != null)
                {
                    return;
                }

                var bind = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                bind.MaxReceivedMessageSize = 2147483647;
                bind.MaxBufferSize          = 2147483647;
                // Commented next statement since it is not required
                bind.MaxBufferPoolSize                   = 2147483647;
                bind.ReaderQuotas.MaxArrayLength         = 2147483647;
                bind.ReaderQuotas.MaxBytesPerRead        = 2147483647;
                bind.ReaderQuotas.MaxDepth               = 2147483647;
                bind.ReaderQuotas.MaxStringContentLength = 2147483647;
                bind.ReaderQuotas.MaxNameTableCharCount  = 2147483647;

                mProxy          = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
                mProxy.Faulted += mProxy_Faulted;
            }
        }
Пример #2
0
        public MtClient(int port)
        {
            if (port < 0 || port > 65536)
            {
                throw new ArgumentOutOfRangeException(nameof(port), "port value is invalid");
            }

            Port = port;

            var urlService = $"net.pipe://localhost/{ServiceName}_{port}";

            var bind = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
            {
                MaxReceivedMessageSize = 2147483647,
                MaxBufferSize          = 2147483647,
                MaxBufferPoolSize      = 2147483647,
                SendTimeout            = new TimeSpan(12, 0, 0),
                ReceiveTimeout         = new TimeSpan(12, 0, 0),
                ReaderQuotas           =
                {
                    MaxArrayLength         = 2147483647,
                    MaxBytesPerRead        = 2147483647,
                    MaxDepth               = 2147483647,
                    MaxStringContentLength = 2147483647,
                    MaxNameTableCharCount  = 2147483647
                }
            };

            _proxy          = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
            _proxy.Faulted += ProxyFaulted;
        }
Пример #3
0
        public void Close()
        {
            Log.Debug("Close: begin.");

            if (_proxy != null)
            {
                _proxy.Faulted -= ProxyFaulted;
                _proxy.Dispose();
                _proxy = null;
            }

            _isConnected = false;

            Log.Debug("Close: end.");
        }
Пример #4
0
        public void Open(string host, int port)
        {
            Log.DebugFormat("Open: begin. host = {0}, port = {1}", host, port);

            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentNullException(nameof(host), "host is null or empty");
            }

            if (port < 0 || port > 65536)
            {
                throw new ArgumentOutOfRangeException(nameof(port), "port value is invalid");
            }

            var urlService = $"net.tcp://{host}:{port}/{ServiceName}";

            if (_proxy != null)
            {
                Log.Warn("Open: end. _proxy is not null.");
                return;
            }

            var bind = new NetTcpBinding(SecurityMode.None)
            {
                MaxReceivedMessageSize = 2147483647,
                MaxBufferSize          = 2147483647,
                MaxBufferPoolSize      = 2147483647,
                SendTimeout            = new TimeSpan(12, 0, 0),
                ReceiveTimeout         = new TimeSpan(12, 0, 0),
                ReaderQuotas           =
                {
                    MaxArrayLength         = 2147483647,
                    MaxBytesPerRead        = 2147483647,
                    MaxDepth               = 2147483647,
                    MaxStringContentLength = 2147483647,
                    MaxNameTableCharCount  = 2147483647
                }
            };

            // Commented next statement since it is not required

            _proxy          = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
            _proxy.Faulted += ProxyFaulted;

            Log.Debug("Open: end.");
        }
Пример #5
0
        public void Open(string host, int port)
        {
            Debug.WriteLine("[INFO] MtClient::Open");

            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentNullException("host", "host is null or empty");
            }

            if (port < 0 || port > 65536)
            {
                throw new ArgumentOutOfRangeException("port", "port value is invalid");
            }

            var urlService = string.Format("net.tcp://{0}:{1}/{2}", host, port, SERVICE_NAME);

            lock (mClientLocker)
            {
                if (mProxy != null)
                {
                    return;
                }

                var bind = new NetTcpBinding(SecurityMode.None)
                {
                    MaxReceivedMessageSize = 2147483647,
                    MaxBufferSize          = 2147483647,
                    MaxBufferPoolSize      = 2147483647,
                    ReaderQuotas           =
                    {
                        MaxArrayLength         = 2147483647,
                        MaxBytesPerRead        = 2147483647,
                        MaxDepth               = 2147483647,
                        MaxStringContentLength = 2147483647,
                        MaxNameTableCharCount  = 2147483647
                    }
                };
                // Commented next statement since it is not required

                mProxy          = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
                mProxy.Faulted += mProxy_Faulted;
            }
        }
Пример #6
0
        public MtClient(string host, int port)
        {
            if (string.IsNullOrEmpty(host))
            {
                throw new ArgumentNullException(nameof(host), "host is null or empty");
            }

            if (port < 0 || port > 65536)
            {
                throw new ArgumentOutOfRangeException(nameof(port), "port value is invalid");
            }

            Host = host;
            Port = port;

            var urlService = $"net.tcp://{host}:{port}/{ServiceName}";

            var bind = new NetTcpBinding(SecurityMode.None)
            {
                MaxReceivedMessageSize = 2147483647,
                MaxBufferSize          = 2147483647,
                MaxBufferPoolSize      = 2147483647,
                SendTimeout            = new TimeSpan(12, 0, 0),
                ReceiveTimeout         = new TimeSpan(12, 0, 0),
                ReaderQuotas           =
                {
                    MaxArrayLength         = 2147483647,
                    MaxBytesPerRead        = 2147483647,
                    MaxDepth               = 2147483647,
                    MaxStringContentLength = 2147483647,
                    MaxNameTableCharCount  = 2147483647
                }
            };

            _proxy          = new MtApiProxy(new InstanceContext(this), bind, new EndpointAddress(urlService));
            _proxy.Faulted += ProxyFaulted;
        }