Ejemplo n.º 1
0
    public void OnUpdateFinish(IUpdateExecutor executor, UpdateInfo.ResInfo info, List <string> fileList, bool isNeedReload = false)
    {
        Debug.Log("update " + info.type + " finished, progress:" + (m_currIndex + 1) + "/" + m_updateCount);
        if (!m_isReload && isNeedReload)
        {
            m_isReload = true;
        }


        //flag file existed
        m_context.ResMd5Mgr.Set(info, true, fileList);
        m_currIndex++;
        bool allFinished = ((m_currIndex) == m_updateCount);

        if (allFinished)
        {
            //Version.Instance.SetVersion(VersionType.Resource, info.versionInfo.resVersion);

            if (m_updatefinishCB != null)
            {
                m_updatefinishCB(VersionType.Resource, info.versionInfo.resVersion);
            }

            m_delegate.OnUpdateSuccessed(GameUpdateSys.UpdateResult.Success, m_isReload);

            _UpdateFinished();
        }
    }
Ejemplo n.º 2
0
    public void RegisterUpdateExecutor(IUpdateExecutor exec)
    {
        var t = exec.GetUpdateType();

        if (m_updaterDict.ContainsKey(t))
        {
            Debug.LogError("already registerd this type, ignore:" + t.ToString());
            return;
        }

        m_updaterDict.Add(t, exec);
    }
Ejemplo n.º 3
0
    public void StartResourceUpdate(UpdateCheckResult result, IUpdateSysDelegate del)
    {
        if (m_state == State.Upgrading)
        {
            Debug.LogError("already in upgrading state");
            return;
        }

        if (!result.NeedUpdate)
        {
            Debug.LogError("donot need update");
            return;
        }

        var list = result.ResInfoList;

        if (list == null || list.Count == 0)
        {
            Debug.LogError("empty res list");
            return;
        }

        m_delegate = del;
        _StartUpdate();

        for (int i = 0; i < list.Count; i++)
        {
            var info = list[i];

            IUpdateExecutor executor = GetUpdateExecutor(info.type);
            if (executor != null)
            {
                //JobQueueCoroutine需要重构下更易用
                UpdateResourceParam param = new UpdateResourceParam();
                param.executor = executor;
                param.info     = info;
                param.context  = m_context;

                m_updateCount++;
                m_CoroutineJobQueue.PushJob(_UpdateResCoroutine, param);
            }
            else
            {
                Debug.LogError("UpdateExecutor not registered for type:" + info.type);
            }
        }

        m_CoroutineJobQueue.StartJobCoroutine();
    }
Ejemplo n.º 4
0
        public void handler(object v)
        {
            ProtoBufPackage pack = v as ProtoBufPackage;

            IExecutor handler = null;

            handlers.TryGetValue(pack.NSerialNo, out handler);
            try
            {
                if (handler != null)
                {
                    handler.execute(pack);
                }
                else
                {
                    foreach (IExecutor exec in handlers.Values)
                    {
                        if (typeof(IUpdateExecutor).IsAssignableFrom(exec.GetType()))
                        {
                            IUpdateExecutor upexec = ((IUpdateExecutor)exec);
                            if (((IUpdateExecutor)exec).getnUpdateProtoID() == pack.NProtoID)
                            {
                                upexec.handler(upexec.parse(pack));
                                if (pack.NProtoID == TrdGetOrderFillListExec.nUpdateProtoID || pack.NProtoID == TrdPlaceOrderExec.nUpdateProtoID)//与交易相关的推送是全局推送,不需要根据条件过滤。只需要推送一次就可以了。2208推送订单更新,2218推送新成交
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }catch (Exception e)
            {
                over = true;
            }
        }
Ejemplo n.º 5
0
    public void OnUpdateError(IUpdateExecutor executor, ErrorCode errCode, UpdateInfo.ResInfo info)
    {
        m_delegate.OnUpdateError(errCode);

        _UpdateFinished();
    }