コード例 #1
0
        public void Connect()
        {
            lock (thisLock)
            {
                try
                {
                    server = client.ChannelFactory.CreateChannel();

                    // reduce write timeout
                    IClientChannel channel = server as IClientChannel;
                    channel.OperationTimeout = TimeSpan.FromSeconds(1);

                    server.AddClient(name);

                    connected = true;
                }
                catch // in case of error just not set connected to true
                {
                    connected = false;
                    CloseChannel();
                }
            }
        }
コード例 #2
0
        public void Connect()
        {
            var uri     = new Uri(string.Format("net.tcp://{0}:{1}", ipaddr, port));
            var binding = new NetTcpBinding();

            binding.Name = "MasterConnBinding";
            //binding.SendTimeout = new TimeSpan(0,0,0,0,500); // shorten the timeout when accessing the service
            binding.CloseTimeout           = new TimeSpan(0, 0, 0, 0, 500); // shorten the timeout when closing the channel and there is an error
            binding.MaxReceivedMessageSize = Int32.MaxValue;                // default 65535 is not enough for long plans
            binding.Security.Mode          = SecurityMode.None;
            callback = new MasterServiceCallback();
            client   = new MasterServiceClient(callback, binding, new EndpointAddress(uri));
            server   = client.ChannelFactory.CreateChannel();

            try
            {
                server.AddClient(name);
            }
            catch
            {
                CloseChannel();
                throw new MasterConnectionTimeoutException(ipaddr, port);
            }
        }
コード例 #3
0
        /// <summary>
        /// close the WCF channel
        /// </summary>
        void CloseChannel()
        {
            if (server == null)
            {
                return;
            }

            var channel = server as ICommunicationObject;

            try
            {
                channel.Close();
            }
            catch (CommunicationException)
            {
                channel.Abort();
            }
            catch (TimeoutException)
            {
                channel.Abort();
            }

            server = null;
        }
コード例 #4
0
ファイル: AutoconClient.cs プロジェクト: pjanec/dirigent
        public void Connect()
        {
            lock (thisLock)
            {
                try
                {
                    server = client.ChannelFactory.CreateChannel();

                    // reduce write timeout
                    IClientChannel channel = server as IClientChannel;
                    channel.OperationTimeout = TimeSpan.FromSeconds(1);

                    server.AddClient(name);

                    connected = true;
                }
                catch // in case of error just not set connected to true
                {
                    connected = false;
                    CloseChannel();
                }
            }
        }
コード例 #5
0
ファイル: AutoconClient.cs プロジェクト: pjanec/dirigent
        /// <summary>
        /// close the WCF channel
        /// </summary>
        void CloseChannel()
        {
            if (server == null) return;

            var channel = server as ICommunicationObject;
            try
            {
                channel.Close();
            }
            catch (CommunicationException)
            {
                channel.Abort();
            }
            catch (TimeoutException)
            {
                channel.Abort();
            }

            server = null;
        }