예제 #1
0
        public bool Init(Log.on_log on_log, ISockCallee callee)
        {
            Log.SetLogCallBack(on_log);
            m_gameClient = new GameClient();
            if (m_localClient == null)
            {
                m_localClient = new GameClient();
            }
            m_gameSock = new GameSock();
            if (!m_gameSock.Init(callee))
            {
                return(false);
            }

            ((GameReceiver)m_gameSock.GetGameReceiver()).SetGameClient((GameClient)m_gameClient);
            return(true);
        }
예제 #2
0
        public bool Init(string strDeviceUid, Log.on_log on_log, ISockCallee callee)
        {
            fxVerify.Initalize(strDeviceUid);
            Log.SetLogCallBack(on_log);
            m_gameClient = new GameClient();
            if (m_gameSock != null)
            {
                m_gameSock.Disconnect();
                m_gameSock = null;
            }
            m_gameSock = new GameSock();
            if (!m_gameSock.Init(callee))
            {
                return(false);
            }

            ((GameReceiver)m_gameSock.GetGameReceiver()).SetGameClient((GameClient)m_gameClient);
            return(true);
        }
예제 #3
0
    /* @brief:系统启动注册事件
     *  @return void
     */
    public static void RegistCallback(bool bClear = true)
    {
        ConnectStage.Clear();

        IGameSock iSock = Game.Instance.mGameSock;

        if (iSock != null)
        {
            //连服务器成功后回调
            iSock.RegistCallBack("on_connected", on_connected);
            //连服务器失败后回调
            iSock.RegistCallBack("on_connect_fail", on_connect_fail);
            //网络阻塞
            iSock.RegistCallBack("on_connect_block", on_connect_block);
            //服务器主动关闭回调
            iSock.RegistCallBack("on_close", on_close);
        }
        else
        {
            LogSystem.Log("Error!! ConnectState::RegistCallback iSock is null");
        }
    }
예제 #4
0
파일: Game.cs 프로젝트: mengtest/actdemo
    /// <summary>
    /// 初始化网络模块
    /// </summary>
    public void InitNetWork()
    {
        if (mbNetInit)
        {
            mClientNet.ShutDown();
            mClientNet.UnInit();
        }

        try
        {
            InitVerify();

            mbNetInit   = mClientNet.Init(GlobalData.mDeviceMac, null, null);
            mGameSock   = mClientNet.GetGameSock();
            mGameClient = mClientNet.GetGameClient();
            mGameRecv   = mGameSock.GetGameReceiver();
            mGameSender = mGameSock.GetGameSender();
            GameCommand.SetSender(mGameSender);
        }
        catch (System.Exception e)
        {
            LogSystem.LogError("InitNetWork::", e.ToString());
        }
    }