private void Subscribe(string name = null)
        {
            Enabled = true;

            var eventSvcRemoteFactory = CreateEventServiceRemoteFactory();

            try
            {
                _krEventproxy = eventSvcRemoteFactory.CreateChannel();
                BuildKRService();

                var comObj = _krEventproxy as ICommunicationObject;

                comObj.Faulted += (s, ie) =>
                {
                    //ExceptionEvent?.Invoke(s, "Faulted");
                };
                comObj.Closed += (s, ie) =>
                {
                    //ExceptionEvent?.Invoke(s, "Closed");
                };
                comObj.Closing += (s, ie) =>
                {
                    CommunicationEvent?.Invoke(s, new DataEventArgs("remote host is closed"));
                };

                _krEventproxy.Subscribe(CreateDefaultSubscribeArg(name));
            }
            catch (Exception ex)
            {
                ExceptionEvent?.Invoke(new KRException("Subscribe", "connection error", ex.Message));
            }
        }
 protected void HandleCommunicationEvent(object sender, string args)
 {
     CommunicationEvent?.Invoke(sender, new DataEventArgs(args));
 }
Exemplo n.º 3
0
 protected void OnCommunicationEvent(CommunicationEventArgs args)
 {
     CommunicationEvent?.Invoke(this, args);
 }