public void init() { SFUtils.log("正在连接GameServer..."); m_sendQueue = new Queue <SFBaseRequestMessage>(); m_recvQueue = new Queue <string>(); dispatcher = new SFEventDispatcher(this); m_client = new SFTcpClient(); m_ping = -1; m_heartbeatTimer = SFCommonConf.instance.heatbeatInterval; m_client.init(SFCommonConf.instance.serverIp, SFCommonConf.instance.serverPort, onRecvMsg, ret => { if (ret == 0) { SFUtils.log("连接GameServer成功"); } else { SFUtils.logWarning("连接GameServer失败"); } dispatcher.dispatchEvent(SFEvent.EVENT_NETWORK_READY, new SFSimpleEventData(ret)); }); m_client.dispatcher.addEventListener(this, SFEvent.EVENT_NETWORK_INTERRUPTED, e => { dispatcher.dispatchEvent(e); }); dispatcher.addEventListener(this, SFResponseMsgSocketHeartbeat.pName, onHeartbeat); }
// 私有构造函数 private SFUserData() { dispatcher = new SFEventDispatcher(this); skillConf = new SFUserSkillConf(); skillConf.space = (int)ESkill.FireBall; skillConf.left = (int)ESkill.Flash; skillConf.right = (int)ESkill.Shield; }
public SFTcpClient() { dispatcher = new SFEventDispatcher(this); }
// 私有构造函数 private SFBattleData() { dispatcher = new SFEventDispatcher(this); }