/// <summary> /// Constructor. /// </summary> /// <param name="nameAppending">Additional part to the default named bus (name is {endpoint} + "MessageBus.Proxy" + {appending}).</param> /// <param name="accessControl">Control acces to remote server (user and pass if required), pass null for no login.</param> public ClientMessageBus(IPEndPoint endpoint, string nameAppendix, ClientAccessControl accessControl) : base(endpoint.ToString() + " MessageBus.Proxy " + nameAppendix) { AccessControl = accessControl; _socketClient = new SocketMessageClient(endpoint, base.Serializer); _socketClient.ConnectedEvent += new SocketCommunicator.HelperUpdateDelegate(_messageClient_ConnectedEvent); _socketClient.DisconnectedEvent += new SocketCommunicator.HelperUpdateDelegate(_messageClient_DisconnectedEvent); _socketClient.MessageReceivedEvent += new SocketCommunicator.MessageUpdateDelegate(_messageClient_MessageReceivedEvent); _socketClient.SendAsyncCompleteEvent += new SocketCommunicator.AsyncMessageSendDelegate(_messageClient_SendAsyncCompleteEvent); _socketClient.AutoReconnect = true; _socketClient.KeepAlive = true; base.ClientAddedEvent += new global::Matrix.Framework.MessageBus.Core.MessageBusClientUpdateDelegate(MessageBusNetClient_ClientAddedEvent); base.ClientRemovedEvent += new global::Matrix.Framework.MessageBus.Core.MessageBusClientRemovedDelegate(MessageBusNetClient_ClientRemovedEvent); ApplicationLifetimeHelper.ApplicationClosingEvent += new CommonHelper.DefaultDelegate(ApplicationLifetimeHelper_ApplicationClosingEvent); }
public override void Dispose() { ApplicationLifetimeHelper.ApplicationClosingEvent -= new CommonHelper.DefaultDelegate(ApplicationLifetimeHelper_ApplicationClosingEvent); base.ClientAddedEvent -= new global::Matrix.Framework.MessageBus.Core.MessageBusClientUpdateDelegate(MessageBusNetClient_ClientAddedEvent); base.ClientRemovedEvent -= new global::Matrix.Framework.MessageBus.Core.MessageBusClientRemovedDelegate(MessageBusNetClient_ClientRemovedEvent); base.Dispose(); SocketMessageClient messageClient = _socketClient; _socketClient = null; if (messageClient != null) { messageClient.ConnectedEvent -= new SocketCommunicator.HelperUpdateDelegate(_messageClient_ConnectedEvent); messageClient.DisconnectedEvent -= new SocketCommunicator.HelperUpdateDelegate(_messageClient_DisconnectedEvent); messageClient.MessageReceivedEvent -= new SocketCommunicator.MessageUpdateDelegate(_messageClient_MessageReceivedEvent); messageClient.SendAsyncCompleteEvent -= new SocketCommunicator.AsyncMessageSendDelegate(_messageClient_SendAsyncCompleteEvent); messageClient.Dispose(); } }