123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using FL.Network;
- using XGame.Framework.Network;
- using XGame.Framework.Nodes;
- namespace FL.Nodes.Network
- {
- public class SessionComponent : NodeComponent, INetModuleListener
- {
- INetModule _netModule;
- public override void OnEnable(object intent)
- {
- _netModule = NetModule.Init(Context.Time, new FLMsgGenerator(), this);
- _netModule.Connect(new AddressInfo()
- {
- Address = "flkaifa.xmsgame.com",
- Port = 4001,
- ProtocolType = ProtocolType.WSS
- });
- }
- public override void OnDisable()
- {
- _netModule = null;
- NetModule.Dispose();
- }
- void INetModuleListener.OnHeartbeatTimeout()
- {
- throw new System.NotImplementedException();
- }
- void INetModuleListener.OnConnectStart()
- {
- XGame.Log.Info($"OnConnectStart");
- }
- void INetModuleListener.OnConnected()
- {
- EventSingle.Instance.Notify(EventDefine.ShowTips, "网络连接成功.");
- _netModule.StartHeartbeat();
- //NetModule.Request(new PlayerLoginRequest()
- //{
- // pid = "1",
- //});
- }
- void INetModuleListener.OnDisconnected()
- {
- XGame.Log.Info($"OnDisconnected");
- }
- void INetModuleListener.OnSessionError(SessionEventArgs args)
- {
- XGame.Log.Info($"OnSessionError Args:{args}");
- EventSingle.Instance.Notify(EventDefine.ShowTips, $"网络错误.Args:{args}");
- }
- void INetModuleListener.OnRequest(RequestEventArgs args)
- {
- XGame.Log.Info($"OnRequest Args:{args}");
- }
- void INetModuleListener.OnResponseSeqError(int seqId, int requestId, int responseId)
- {
- XGame.Log.Info($"OnResponseSeqError seqId:{seqId} requestId:{requestId} responseId:{responseId}");
- }
- void INetModuleListener.OnResponseFinish(ResponseEventArgs args)
- {
- XGame.Log.Info($"OnResponseFinish args:{args}");
- }
- }
- }
|