Beispiel #1
0
        /// <summary>
        /// Creates a TV Stream Control, and connects to the specified server
        /// </summary>
        /// <param name="serverAddress">IP or hostname of the server to connect to</param>
        public TVStreamControl(string serverAddress)
        {
            ChannelScanProgress = -1;

            IPHostEntry entry = AddressLookup.GetHostEntry(serverAddress);

            _serverAddress = entry.AddressList[0].ToString();

            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);

            int timeout;

            //get SendTimeout from app.config
            if (Int32.TryParse(ConfigurationManager.AppSettings["GraphControlClientSendTimeout"], out timeout))
            {
                if (timeout > 0)
                {
                    binding.SendTimeout = TimeSpan.FromSeconds(timeout);
                }
            }

            //get CloseTimeout from app.config
            if (Int32.TryParse(ConfigurationManager.AppSettings["GraphControlClientCloseTimeout"], out timeout))
            {
                if (timeout > 0)
                {
                    binding.CloseTimeout = TimeSpan.FromSeconds(timeout);
                }
            }

            TVStreamControlCallback callback = new TVStreamControlCallback(this);

            _proxyFactory          = new DuplexChannelFactory <ITVStream>(callback, binding, @"net.tcp://" + ServerAddress + @":8099/TVStreamService");
            _proxyFactory.Opening += new EventHandler(Proxy_Opening);
            _proxyFactory.Opened  += new EventHandler(Proxy_Opened);
            _proxyFactory.Closing += new EventHandler(Proxy_Closing);
            _proxyFactory.Closed  += new EventHandler(Proxy_Closed);
            _proxyFactory.Faulted += new EventHandler(Proxy_Faulted);
            _proxyFactory.Open();
            _proxy = _proxyFactory.CreateChannel();

            _serverKeepAliveTimer          = new System.Timers.Timer();
            _serverKeepAliveTimer.Interval = 15000;
            _serverKeepAliveTimer.Elapsed += new System.Timers.ElapsedEventHandler(ServerKeepAliveTimer_Elapsed);
            _serverKeepAliveTimer.Enabled  = true;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new instance
        /// </summary>
        /// <param name="serverAddress">server hostname or ip address</param>
        /// <param name="recordCallback">the <see cref="T:IRecordCallback"/> you want to use</param>
        public RecordClient(string serverAddress, IRecordCallback recordCallback)
        {
            IPHostEntry entry = AddressLookup.GetHostEntry(serverAddress);

            _serverAddress = entry.AddressList[0].ToString();

            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);

            //  binding.SendTimeout = TimeSpan.FromSeconds(Convert.ToInt32(ConfigurationManager.AppSettings["GraphControlClientSendTimeout"]));
            _proxyFactory          = new DuplexChannelFactory <IRecord>(recordCallback, binding, @"net.tcp://" + ServerAddress + @":8099/RecordService");
            _proxyFactory.Opening += new EventHandler(Proxy_Opening);
            _proxyFactory.Opened  += new EventHandler(Proxy_Opened);
            _proxyFactory.Closing += new EventHandler(Proxy_Closing);
            _proxyFactory.Closed  += new EventHandler(Proxy_Closed);
            _proxyFactory.Faulted += new EventHandler(Proxy_Faulted);
            _proxyFactory.Open();
            _proxy = _proxyFactory.CreateChannel();
            _serverKeepAliveTimer          = new System.Timers.Timer();
            _serverKeepAliveTimer.Interval = 15000;
            _serverKeepAliveTimer.Elapsed += new System.Timers.ElapsedEventHandler(ServerKeepAliveTimer_Elapsed);
            _serverKeepAliveTimer.Enabled  = true;
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a connection to the specified server
        /// </summary>
        /// <param name="serverAddress">server hostname or IP address</param>
        public GraphControl(string serverAddress)
        {
            IPHostEntry entry = AddressLookup.GetHostEntry(serverAddress);

            _serverAddress = entry.AddressList[0].ToString();

            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);

            int sendTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["GraphControlClientSendTimeout"]);

            if (sendTimeout == 0)
            {
                sendTimeout = 20;
            }
            binding.SendTimeout = TimeSpan.FromSeconds(sendTimeout);

            int closeTimeout = Convert.ToInt32(ConfigurationManager.AppSettings["GraphControlClientCloseTimeout"]);

            if (closeTimeout == 0)
            {
                closeTimeout = 5;
            }
            binding.CloseTimeout = TimeSpan.FromSeconds(closeTimeout);

            _proxyFactory          = new ChannelFactory <IStream>(binding, @"net.tcp://" + ServerAddress + @":8098/StreamService");
            _proxyFactory.Opening += new EventHandler(Proxy_Opening);
            _proxyFactory.Opened  += new EventHandler(Proxy_Opened);
            _proxyFactory.Closing += new EventHandler(Proxy_Closing);
            _proxyFactory.Closed  += new EventHandler(Proxy_Closed);
            _proxyFactory.Faulted += new EventHandler(Proxy_Faulted);
            _proxyFactory.Open();
            _proxy = _proxyFactory.CreateChannel();

            _serverKeepAliveTimer          = new System.Timers.Timer();
            _serverKeepAliveTimer.Interval = 15000;
            _serverKeepAliveTimer.Elapsed += new System.Timers.ElapsedEventHandler(ServerKeepAliveTimer_Elapsed);
            _serverKeepAliveTimer.Enabled  = true;
        }
Beispiel #4
0
        /// <param name="serverHostOrIP">server hostname or IP that is hosting the service</param>
        public BaseClient(string serverHostOrIP)
        {
            IPHostEntry e = AddressLookup.GetHostEntry(serverHostOrIP);

            this.ServerAddress = e.AddressList[0].ToString();
        }