PeerEvent.cs 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. namespace ENet
  3. {
  4. public class PeerEvent
  5. {
  6. private Action<Event> connected;
  7. private Action<Event> received;
  8. private Action<Event> disconnect;
  9. public Action<Event> Connected
  10. {
  11. get
  12. {
  13. return this.connected;
  14. }
  15. set
  16. {
  17. this.connected = value;
  18. }
  19. }
  20. public Action<Event> Received
  21. {
  22. get
  23. {
  24. return this.received;
  25. }
  26. set
  27. {
  28. this.received = value;
  29. }
  30. }
  31. public Action<Event> Disconnect
  32. {
  33. get
  34. {
  35. return this.disconnect;
  36. }
  37. set
  38. {
  39. this.disconnect = value;
  40. }
  41. }
  42. internal void OnConnected(Event e)
  43. {
  44. if (this.connected == null)
  45. {
  46. return;
  47. }
  48. this.connected(e);
  49. }
  50. internal void OnReceived(Event e)
  51. {
  52. if (this.received == null)
  53. {
  54. return;
  55. }
  56. this.received(e);
  57. }
  58. internal void OnDisconnect(Event e)
  59. {
  60. if (this.disconnect == null)
  61. {
  62. return;
  63. }
  64. this.disconnect(e);
  65. }
  66. }
  67. }