예제 #1
0
 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);
 }
예제 #2
0
 // 私有构造函数
 private SFUserData()
 {
     dispatcher      = new SFEventDispatcher(this);
     skillConf       = new SFUserSkillConf();
     skillConf.space = (int)ESkill.FireBall;
     skillConf.left  = (int)ESkill.Flash;
     skillConf.right = (int)ESkill.Shield;
 }
예제 #3
0
 public SFTcpClient()
 {
     dispatcher = new SFEventDispatcher(this);
 }
예제 #4
0
 // 私有构造函数
 private SFBattleData()
 {
     dispatcher = new SFEventDispatcher(this);
 }