SessionComponent.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using FL.Network;
  2. using XGame.Framework.Network;
  3. using XGame.Framework.Nodes;
  4. namespace FL.Nodes.Network
  5. {
  6. public class SessionComponent : NodeComponent, INetModuleListener
  7. {
  8. INetModule _netModule;
  9. public override void OnEnable(object intent)
  10. {
  11. _netModule = NetModule.Init(Context.Time, new FLMsgGenerator(), this);
  12. _netModule.Connect(new AddressInfo()
  13. {
  14. Address = "flkaifa.xmsgame.com",
  15. Port = 4001,
  16. ProtocolType = ProtocolType.WSS
  17. });
  18. }
  19. public override void OnDisable()
  20. {
  21. _netModule = null;
  22. NetModule.Dispose();
  23. }
  24. void INetModuleListener.OnHeartbeatTimeout()
  25. {
  26. throw new System.NotImplementedException();
  27. }
  28. void INetModuleListener.OnConnectStart()
  29. {
  30. XGame.Log.Info($"OnConnectStart");
  31. }
  32. void INetModuleListener.OnConnected()
  33. {
  34. XGame.Log.Info($"OnConnected");
  35. //_netModule.StartHeartbeat();
  36. //NetModule.Request(new PlayerLoginRequest()
  37. //{
  38. // pid = "1",
  39. //});
  40. }
  41. void INetModuleListener.OnDisconnected()
  42. {
  43. XGame.Log.Info($"OnDisconnected");
  44. }
  45. void INetModuleListener.OnSessionError(SessionEventArgs args)
  46. {
  47. XGame.Log.Info($"OnSessionError Args:{args}");
  48. }
  49. void INetModuleListener.OnRequest(RequestEventArgs args)
  50. {
  51. XGame.Log.Info($"OnRequest Args:{args}");
  52. }
  53. void INetModuleListener.OnResponseSeqError(int seqId, int requestId, int responseId)
  54. {
  55. XGame.Log.Info($"OnResponseSeqError seqId:{seqId} requestId:{requestId} responseId:{responseId}");
  56. }
  57. void INetModuleListener.OnResponseFinish(ResponseEventArgs args)
  58. {
  59. XGame.Log.Info($"OnResponseFinish args:{args}");
  60. }
  61. }
  62. }