PeerEvent.cs 963 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 event Action<Event> Connected
  10. {
  11. add
  12. {
  13. this.connected += value;
  14. }
  15. remove
  16. {
  17. this.connected -= value;
  18. }
  19. }
  20. public event Action<Event> Received
  21. {
  22. add
  23. {
  24. this.received += value;
  25. }
  26. remove
  27. {
  28. this.received -= value;
  29. }
  30. }
  31. public event Action<Event> Disconnect
  32. {
  33. add
  34. {
  35. this.disconnect += value;
  36. }
  37. remove
  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. }