NetOuterComponentSystem.cs 957 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Net;
  2. using Model;
  3. namespace Hotfix
  4. {
  5. [ObjectEvent]
  6. public class NetOuterComponentEvent : ObjectEvent<NetOuterComponent>, IAwake, IAwake<IPEndPoint>, IUpdate
  7. {
  8. public void Awake()
  9. {
  10. this.Get().Awake();
  11. }
  12. public void Awake(IPEndPoint ipEndPoint)
  13. {
  14. this.Get().Awake(ipEndPoint);
  15. }
  16. public void Update()
  17. {
  18. this.Get().Update();
  19. }
  20. }
  21. public static class NetOuterComponentSystem
  22. {
  23. public static void Awake(this NetOuterComponent self)
  24. {
  25. self.Awake(NetworkProtocol.KCP);
  26. self.MessagePacker = new ProtobufPacker();
  27. self.MessageDispatcher = new OuterMessageDispatcher();
  28. }
  29. public static void Awake(this NetOuterComponent self, IPEndPoint ipEndPoint)
  30. {
  31. self.Awake(NetworkProtocol.KCP, ipEndPoint);
  32. self.MessagePacker = new ProtobufPacker();
  33. self.MessageDispatcher = new OuterMessageDispatcher();
  34. }
  35. public static void Update(this NetOuterComponent self)
  36. {
  37. self.Update();
  38. }
  39. }
  40. }