EventServiceClient.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Aitex.Core.WCF;
  6. using Aitex.Core.RT.Event;
  7. using System.ServiceModel;
  8. using Aitex.Core.WCF.Interface;
  9. namespace Aitex.Core.WCF
  10. {
  11. public class EventServiceClient : DuplexChannelServiceClientWrapper<IEventService>, IEventService
  12. {
  13. public event Action<EventItem> OnEvent;
  14. public EventServiceClient(EventServiceCallback callbackInstance)
  15. : base(new InstanceContext(callbackInstance), "Client_IEventService", "EventService")
  16. {
  17. callbackInstance.FireEvent += new Action<EventItem>(callbackInstance_FireEvent);
  18. }
  19. void callbackInstance_FireEvent(EventItem obj)
  20. {
  21. if (OnEvent != null)
  22. {
  23. OnEvent(obj);
  24. }
  25. }
  26. public bool Register(Guid id)
  27. {
  28. bool ret = false;
  29. Invoke(svc => { ret = svc.Register(id); });
  30. return ret;
  31. }
  32. public void UnRegister(Guid id)
  33. {
  34. Invoke(svc => { svc.UnRegister(id); });
  35. }
  36. }
  37. }