public bool Initialize(Uri serverAddressUri)
        {
            lock (this)
            {
                EndpointAddress serverAddress = new EndpointAddress(serverAddressUri);

                try
                {
                    // If you get a configuration exception here in debug mode, just *ignore it* (disable it from Debug >> Exceptions),
                    // normal execution exceptions is just one more of the WCFs excellent features:
                    // see more here: http://ari-techno.blogspot.com/2008/08/this-element-is-not-currently.html

                    _channelFactory = new DuplexChannelFactory <IMessageContainerTransport>(
                        this, MessageContainerTransportServer.CreateBinding(), serverAddress);
                }
                catch (ConfigurationErrorsException)
                {// This is a dummy catch, just to shut the debugger up.
                }

                lock (Clients)
                {
                    if (Clients.Contains(this) == false)
                    {
                        Clients.Add(this);

                        if (Clients.Count == 1)
                        {// We are the single new starting client, fire the connection monitoring thread.
                            GeneralHelper.FireAndForget(ConnectionMonitorThread);
                        }
                    }
                }
            }

            return(true);
        }
 public void ChangeServerAddressUri(Uri serverAddressUri)
 {
     lock (this)
     {
         EndpointAddress serverAddress = new EndpointAddress(serverAddressUri);
         _channelFactory = new DuplexChannelFactory <IMessageContainerTransport>(
             this, MessageContainerTransportServer.CreateBinding(), serverAddress);
         _proxyServerInterface = null;
     }
 }
        public override bool ArbiterInitialize(Arbiter arbiter)
        {
            bool result = base.ArbiterInitialize(arbiter);

            _transportServer = new MessageContainerTransportServer();
            if (_transportServer.Initialize(_serverUriBase) == false)
            {
                base.ArbiterUnInitialize();

                _transportServer = null;
                return false;
            }

            _transportServer.MessageContainerReceivedEvent += new HandlerDelegate<String, MessageContainer>(_transport_MessageReceivedEvent);
            _transportServer.ClientConnected += new HandlerDelegate<string>(_transportServer_ClientConnected);
            _transportServer.ClientDisConnected += new HandlerDelegate<string>(_transportServer_ClientDisconnected);

            return result;
        }
        public override bool ArbiterUnInitialize()
        {
            bool result = base.ArbiterUnInitialize();

            if (_transportServer != null)
            {
                _transportServer.UnInitialize();
                _transportServer = null;
            }

            return result;
        }