internal void CreateFactories() { CloseFactories(); BroadcastChannels = new BroadcastChannels <T>(Settings.Server, Settings.Port, BroadcastInstance); BroadcastChannels.OpenChannelAction = delegate { KeyedByTypeCollection <IEndpointBehavior> behaviors = BroadcastChannels.ChannelBroadcastFactory.Endpoint.Behaviors; if (behaviors.Find <ErrorClientBehavior>() == null) { var handler = new ClientErrorHandler <MT, T>(this, BroadcastChannels.ChannelBroadcastFactory); BroadcastChannels.ChannelBroadcastFactory .Opening += (delegate { behaviors.Add(new ErrorClientBehavior(handler)); }); } }; NetTcpBinding binding = Channels.GetBinding(); MainChannelFactory = new DuplexChannelFactory <MT, T> (BroadcastChannels.Callback, binding, new EndpointAddress(ServerAddress)); MainChannelFactory.Opened += delegate { AfterMainChannelOpened(); }; AfterCreateChannels(binding); }
public void Connect() { _ses = _fc.Connect(); _ses.MessageHandler = new ClientMessageHandler(); var eh = new ClientErrorHandler(); _ses.ErrorHandler = eh; Global.ErrorHandler = eh; }