Exemplo n.º 1
0
        public void OnFeedback(string url, string error, string reply, System.Object userData)
        {
            bool result;

            if (string.IsNullOrEmpty(error))
            {
                Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable;
                if (hashtable != null)
                {
                    if (DBTextResource.ParseI(hashtable["result"].ToString()) == 1)
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    result = false;
                }
            }
            else
            {
                result = false;
            }
            mPostFeedbackCallback?.Invoke(result);
        }
Exemplo n.º 2
0
    /// <summary>
    /// 先试图从预加载的bundle缓存中加载ai文件
    /// </summary>
    /// <param name="ai_file"></param>
    bool TryLoadAIFileImmediate(string ai_file)
    {
        // 先从缓存中读取ai文件的资源
        string path       = string.Format(AI_PATH_PREFIX + "/{0}", ai_file);
        var    text_asset = ResourceLoader.Instance.try_load_cached_asset(path) as TextAsset;

        if (text_asset == null)
        {
            return(false);
        }

        // 解析失败则将Hashtable对象放回内存池
        var options = MiniJSON.JsonDecode(text_asset.text) as Hashtable;

        if (options == null)
        {
            //Resources.UnloadAsset(text_asset);
            return(false);
        }

        //Resources.UnloadAsset(text_asset);

        // 解析成功创建BehaviourTree对象
        var behaviourTree = new BehaviourTree.BehaviourTree(ai_file, options, this);

        ObjCachePoolMgr.Instance.RecycleCSharpObject(options, ObjCachePoolType.AIJSON, ai_file);

        SetBehaviourTree(behaviourTree);
        return(true);
    }
Exemplo n.º 3
0
        public void OnPostRoleInfoFinished(string url, string error, string reply, System.Object userData)
        {
            int       result    = 0;
            Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable;

            if (hashtable != null)
            {
                result = DBTextResource.ParseI(hashtable["result"].ToString());
            }

            if (result != 1)
            {
                if (mPostRoleInfoTimer != null)
                {
                    mPostRoleInfoTimer.Destroy();
                    mPostRoleInfoTimer = null;
                }
                // 超过10次就不要再尝试了
                if (mPostRoleInfoTimes <= 10)
                {
                    mPostRoleInfoTimer = new Utils.Timer(3000, false, 3000, PostRoleInfoWithDelay);

                    mPostRoleInfoTimes++;
                }
                else
                {
                    mPostRoleInfoTimes = 0;
                }
            }
            else
            {
                mPostRoleInfoTimes = 0;
            }
        }
Exemplo n.º 4
0
    public void             PlayServicesReceiveAgentEvent(string json)
    {
        Hashtable         data = MiniJSON.JsonDecode(json) as Hashtable;
        PlayServicesEvent e    = (PlayServicesEvent)int.Parse(data["eid"].ToString());

        switch (e)
        {
        case PlayServicesEvent.OnConnectionFailed:
        case PlayServicesEvent.OnConnectionSuccess:
            if (OnPlayServicesEvent != null)
            {
                OnPlayServicesEvent(e);
            }
            break;

        case PlayServicesEvent.OnStateLoadConflict:
            if (OnStateConflict != null)
            {
                OnStateConflict(0, "", null, null);
            }
            break;

        case PlayServicesEvent.OnStateLoaded:
            if (OnStateLoaded != null)
            {
                OnStateLoaded(0, 0, null);
            }
            break;
        }
    }
Exemplo n.º 5
0
        public int n32SkipBalance;      //是否跳过BS认证

        public ErrorCode Load()
        {
            Hashtable json;

            try
            {
                string content = File.ReadAllText(@".\Config\GSCfg.json");
                json = ( Hashtable )MiniJSON.JsonDecode(content);
            }
            catch (Exception e)
            {
                Logger.Error($"load GSCfg.xml failed for {e}");
                return(ErrorCode.CfgFailed);
            }

            this.sCSIP           = json.GetString("IP");
            this.n32CSPort       = json.GetInt("Port");
            this.n32CSMaxMsgSize = json.GetInt("MsgMaxSize");
            this.aszMyUserPwd    = json.GetString("PWD");
            this.n32GSID         = json.GetInt("GSID");
            this.sGCListenIP     = json.GetString("ListenIP");
            this.n32GCListenPort = json.GetInt("ListenPort");
            this.n32GCMaxMsgSize = json.GetInt("MsgMaxSize");
            this.n32MaxGCNum     = json.GetInt("MaxGCNum");
            this.sBSListenIP     = json.GetString("BSIP");
            this.n32BSListenPort = json.GetInt("BSPort");
            this.n32SkipBalance  = json.GetInt("IfSkipBS");

            return(ErrorCode.Success);
        }
Exemplo n.º 6
0
        private ErrorCode LoadDBCfg()
        {
            Hashtable json;

            try
            {
                string content = File.ReadAllText(@".\Config\CSDBCfg.json");
                json = ( Hashtable )MiniJSON.JsonDecode(content);
            }
            catch (Exception e)
            {
                Logger.Error($"load CSDBCfg failed:{e}");
                return(ErrorCode.CfgFailed);
            }
            Hashtable[] dbs = json.GetMapArray("DB");
            foreach (Hashtable db in dbs)
            {
                DBCfg  cfg   = new DBCfg();
                DBType dtype = ( DBType )db.GetInt("type");
                cfg.aszDBHostIP      = db.GetString("ip");
                cfg.un32DBHostPort   = db.GetInt("port");
                cfg.aszDBUserName    = db.GetString("user");
                cfg.aszDBUserPwd     = db.GetString("pwd");
                cfg.aszDBName        = db.GetString("dbname");
                this.dbCfgMap[dtype] = cfg;
            }
            return(ErrorCode.Success);
        }
Exemplo n.º 7
0
        public ErrorCode Initialize(Options opts)
        {
#if !DISABLE_LUA
            XLua.XLuaGenIniterRegister.Init();
            XLua.WrapPusher.Init();
            XLua.DelegatesGensBridge.Init();

            this._luaEnv = new XLua.LuaEnv();
            this._luaEnv.AddLoader(( ref string filepath ) => File.ReadAllBytes(Path.Combine(opts.scriptPath, filepath + ".lua")));
            this._luaEnv.DoString("require \"gs\"");
#endif
            this.config         = new GSConfig();
            this.config.defPath = opts.defs;
            if (string.IsNullOrEmpty(opts.cfg))
            {
                this.config.CopyFromCLIOptions(opts);
                return(ErrorCode.Success);
            }
            try
            {
                this.config.CopyFromJson(( Hashtable )MiniJSON.JsonDecode(File.ReadAllText(opts.cfg)));
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(ErrorCode.CfgLoadFailed);
            }
            this.ReloadDefs();
            return(ErrorCode.Success);
        }
Exemplo n.º 8
0
Arquivo: CS.cs Projeto: niuniuzhu/KOW
        public ErrorCode Initialize(Options opts)
        {
#if !DISABLE_LUA
            XLua.XLuaGenIniterRegister.Init();
            XLua.WrapPusher.Init();
            XLua.DelegatesGensBridge.Init();

            this._luaEnv = new XLua.LuaEnv();
            this._luaEnv.AddLoader(( ref string filepath ) => File.ReadAllBytes(Path.Combine(opts.scriptPath, filepath + ".lua")));
            this._luaEnv.DoString("require \"cs\"");
#endif
            this.config           = new CSConfig();
            this.config.defPath   = opts.defs;
            this.config.goodsPath = opts.goods;
            if (string.IsNullOrEmpty(opts.cfg))
            {
                this.config.CopyFromCLIOptions(opts);
            }
            else
            {
                this.config.CopyFromJson(( Hashtable )MiniJSON.JsonDecode(File.ReadAllText(opts.cfg)));
            }

            this.matchMgr.InitFromDefs(( Hashtable )MiniJSON.JsonDecode(File.ReadAllText(this.config.matchDefs)));

            this.LoadDefs();
            this.LoadGoods();
            return(ErrorCode.Success);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Hashtable json = ( Hashtable )MiniJSON.JsonDecode(Encoding.UTF8.GetString(Resources.matching));

            Hashtable[] instanceDefs = json.GetMapArray("instances");
            foreach (Hashtable instanceDef in instanceDefs)
            {
                MatchSystem matchSystem = new MatchSystem();
                matchSystem.InitFromDefs(instanceDef);
                _matchingSystems.Add(matchSystem);
            }

            _matchingSystems[0].eventHandler = (t, u, s) =>
            {
                switch (t)
                {
                case MatchEvent.Type.MatchSuccess:
                    Console.WriteLine("success:" + s.Dump());
                    break;
                }
            };

            _inputHandler = new InputHandler {
                cmdHandler = HandleInput
            };
            _inputHandler.Start();

            MainLoop();
        }
Exemplo n.º 10
0
    public static Hashtable ReadJsonFile(string fileName)
    {
        if (!System.IO.File.Exists(fileName))
        {
            return(new Hashtable());
        }

        System.IO.StreamReader sr = new System.IO.StreamReader(fileName);
        string fileStr            = "";
        string fileLine;

        while ((fileLine = sr.ReadLine()) != null)
        {
            fileLine = fileLine.Trim();
            if (fileLine.Length >= 2 && fileLine[0] == '/' && fileLine[1] == '/')
            {
                continue;
            }

            fileStr += fileLine;
        }

        Hashtable tbl = (Hashtable)MiniJSON.JsonDecode(fileStr);

        sr.Close();
        return(tbl);
    }
Exemplo n.º 11
0
        private ErrorCode LoadServerList()
        {
            Hashtable json;

            try
            {
                string content = File.ReadAllText(@".\Config\SrvList.json");
                json = ( Hashtable )MiniJSON.JsonDecode(content);
            }
            catch (Exception e)
            {
                Logger.Error($"load SrvList failed for {e}\n");
                return(ErrorCode.CfgFailed);
            }

            Hashtable mainList = json.GetMap("MainList");
            int       listnum  = mainList.GetInt("ServerNum");

            for (uint i = 1; i <= listnum; ++i)
            {
                string     server_name = mainList.GetString($"Name{i}");
                string     server_addr = mainList.GetString($"Addr{i}");
                string[]   pair        = server_addr.Split(':');
                ServerAddr serveraddr  = new ServerAddr
                {
                    str_name = server_name,
                    str_addr = pair[0],
                    str_port = int.Parse(pair[1])
                };
                this.gAllServerAddr.Add(serveraddr);
            }
            return(ErrorCode.Success);
        }
Exemplo n.º 12
0
    // TODO: Setup server
    private IEnumerator StartUrlLocator()
    {
        int attempt = 0;

        Debug.Log("[UrlLocator::StartUrlLocator] - connect to director");
        WWW www;

        do
        {
            Debug.Log("Connecting to: " + url + pid);
            www = new WWW(url + pid);
            yield return(www);

            if (www.error == null)
            {
                break;
            }
            yield return(new WaitForSeconds(0.05f));

            attempt++;
            Logger.trace("[UrlLocator::StartUrlLocator] - attempt to connect to director number " + attempt);
        } while (www.error != null && 5 > attempt);

        // Temporary
        goto force_success;

        if (www.error == null)
        {
            Hashtable table = (Hashtable)MiniJSON.JsonDecode(www.text);
            int       flags = 0;
            Logger.trace("[UrlLocator::StartUrlLocator] - table has " + table.Count + " entries ");
            foreach (DictionaryEntry de in table)
            {
                Debug.Log("key:" + de.Key + ", value: " + de.Value);
                if ("ip" == (string)de.Key)
                {
                    ip     = (string)de.Value;
                    flags |= 1;
                }
                else if ("port" == (string)de.Key)
                {
                    double d = (double)de.Value;
                    port   = (int)d;
                    flags |= 2;
                }
            }
            success = (3 == flags);
        }
        else
        {
            Logger.trace("[UrlLocator::Start] There was an error " + www.error.ToString());
        }
        complete = true;

force_success:
        ip       = "localhost";
        port     = 9933;
        success  = true;
        complete = true;
    }
Exemplo n.º 13
0
        public bool Init(string filename)
        {
            IBridge bridge     = DBOSManager.getDBOSManager().getBridge();
            string  targetPath = bridge.getGameResPath();

            filePath = targetPath + filename + ".json";

            instanceMap[filePath] = this;

            if (File.Exists(filePath))
            {
                string    str   = File.ReadAllText(filePath);
                Hashtable table = MiniJSON.JsonDecode(str) as Hashtable;
                if (table != null)
                {
                    playerPrefsMap[filePath] = table;
                    return(true);
                }
                else
                {
                    playerPrefsMap[filePath] = new Hashtable();
                    GameDebug.LogError("Get PlayerPrefs error!!! filePath: " + filePath);
                }
            }
            else
            {
                playerPrefsMap[filePath] = new Hashtable();

                //GameDebug.LogError("Get PlayerPrefs error, file not exists!!! filePath: " + filePath);
                return(true);
            }

            return(false);
        }
Exemplo n.º 14
0
        public ErrorCode Load()
        {
            Hashtable json;

            try
            {
                string content = File.ReadAllText(@".\Config\BSCfg.json");
                json = ( Hashtable )MiniJSON.JsonDecode(content);
            }
            catch (Exception e)
            {
                Logger.Error($"load GSCfg failed for {e}");
                return(ErrorCode.CfgFailed);
            }

            Hashtable mainGate   = json.GetMap("MainGate");
            Hashtable mainClient = json.GetMap("MainClient");
            Hashtable mainLogin  = json.GetMap("MainLogin");

            this.client_listen_port = mainClient.GetInt("ListernPortForClient");
            this.ls_ip          = mainLogin.GetString("LSIP");
            this.ls_port        = mainLogin.GetInt("LSPort");
            this.gs_listen_port = mainGate.GetInt("ListernPortForGate");
            this.gs_base_index  = mainGate.GetInt("GateBaseIndex");
            this.gs_max_count   = mainGate.GetInt("GateMaxCount");
            this.gs_full_count  = mainGate.GetInt("GateFullCount");

            for (int i = 1; i <= this.gs_max_count; ++i)
            {
                string server_address    = mainGate.GetString($"GateServer{i}");
                string server_address_ex = mainGate.GetString($"GateServer{i}Export");
                this.gs_ip_list.Add(server_address);
                int       key       = this.gs_base_index + i - 1;
                OneGsInfo oneGsInfo = new OneGsInfo
                {
                    gs_Id       = key,
                    gs_nets     = 0,
                    gs_isLost   = true,
                    gs_gc_count = 0
                };
                this.allGsInfo[key] = oneGsInfo;
                {
                    string[] pair = server_address.Split(':');
                    oneGsInfo.gs_Ip   = pair[0];
                    oneGsInfo.gs_Port = int.Parse(pair[1]);
                }
                {
                    string[] pair = server_address_ex.Split(':');
                    oneGsInfo.gs_IpExport = pair[0];
                    int exPos = int.Parse(pair[1]);
                    if (exPos > 0)
                    {
                        Tools.GetNetIP(ref oneGsInfo.gs_IpExport, exPos);
                    }
                }
            }
            return(ErrorCode.Success);
        }
Exemplo n.º 15
0
 public void     NemoActivityReceiveAgentEvent(string json)
 {
     if (OnActivityEvent != null)
     {
         Hashtable         data = (Hashtable)MiniJSON.JsonDecode(json);
         NemoActivityEvent e    = (NemoActivityEvent)int.Parse(data["eid"].ToString());
         OnActivityEvent(e);
     }
 }
Exemplo n.º 16
0
        static Interpreter()
        {
            Hashtable bufferReadWrite = ( Hashtable )MiniJSON.JsonDecode(Resources.convertions);

            BUFFER_WRITE    = bufferReadWrite.GetMap("write");
            BUFFER_READ     = bufferReadWrite.GetMap("read");
            CONVERTIONS     = bufferReadWrite.GetMap("convert");
            DTO_TEMPLATE    = Resources.dto_template;
            PACKET_TEMPLATE = Resources.packet_template;
            MGR_TEMPLATE    = Resources.mgr_template;
        }
Exemplo n.º 17
0
        /// <summary>
        /// 初始化映射表
        /// </summary>
        public void Init(string filePath)
        {
            if (!File.Exists(filePath))
            {
                Debug.LogError("ResNameMapping init fail,file is not exist: " + filePath);
                return;
            }

            FileStream fileStream = null;

            try
            {
                fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

                var bytes = new byte[fileStream.Length];
                fileStream.Read(bytes, 0, bytes.Length);

                var mappingText = Encoding.UTF8.GetString(bytes);
                if (!string.IsNullOrEmpty(mappingText))
                {
                    var nameTable = MiniJSON.JsonDecode(mappingText) as Hashtable;

                    if (nameTable != null)
                    {
                        foreach (DictionaryEntry nameMap in nameTable)
                        {
                            string key   = nameMap.Key.ToString();
                            string value = nameMap.Value.ToString();
                            mNameMapping[key] = value;
                        }
                    }
                }
                else
                {
                    GameDebug.LogError("ResNameMapping init error: hashtable is null");
                }
            }
            catch (Exception e)
            {
                GameDebug.LogError("ResNameMapping init error: " + e.Message);

                if (fileStream != null)
                {
                    fileStream.Close();
                    fileStream = null;
                }
            }

            if (fileStream != null)
            {
                fileStream.Close();
                fileStream = null;
            }
        }
Exemplo n.º 18
0
        public static void Load(string json)
        {
            json = REGEX.Replace(json, string.Empty);
            Hashtable defs = ( Hashtable )MiniJSON.JsonDecode(json);

            _defs.Clear();
            foreach (DictionaryEntry de in defs)
            {
                _defs[de.Key] = de.Value;
            }
            binary = ByteString.CopyFrom(json, Encoding.UTF8);
        }
Exemplo n.º 19
0
        public Config(string content)
        {
            Hashtable json = ( Hashtable )MiniJSON.JsonDecode(content);

            this.version = json.GetString("version");
            ArrayList list = json.GetList("tasks");

            this.tasks = new Task[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                this.tasks[i] = new Task(( Hashtable )list[i]);
            }
        }
Exemplo n.º 20
0
 public ErrorCode Initialize(Options opts)
 {
     try
     {
         this.config = new DBConfig();
         this.config.CopyFromJson(( Hashtable )MiniJSON.JsonDecode(File.ReadAllText(opts.cfg)));
     }
     catch (System.Exception e)
     {
         Logger.Error(e);
         return(ErrorCode.CfgLoadFailed);
     }
     return(ErrorCode.Success);
 }
Exemplo n.º 21
0
        public void OnGetChannelList(string url, string error, string reply, System.Object userData)
        {
            if (string.IsNullOrEmpty(error) == false)
            {
                GameDebug.LogError("OnGetChannelList error: " + error);
                return;
            }

            mChannelList = new List <ChannelInfo>();
            mChannelList.Clear();

            Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable;

            if (hashtable != null)
            {
                if (DBTextResource.ParseI(hashtable["result"].ToString()) == 1)
                {
                    ArrayList arrayList = hashtable["args"] as ArrayList;
                    if (arrayList != null)
                    {
                        foreach (System.Object o in arrayList)
                        {
                            Hashtable channelInfoHashtable = o as Hashtable;
                            if (channelInfoHashtable != null && channelInfoHashtable.Count > 0)
                            {
                                ChannelInfo channelInfo = new ChannelInfo();
                                channelInfo.Id    = System.Convert.ToUInt32(channelInfoHashtable["id"]);
                                channelInfo.Name  = System.Convert.ToString(channelInfoHashtable["name"]);
                                channelInfo.Title = System.Convert.ToString(channelInfoHashtable["title"]);

                                mChannelList.Add(channelInfo);
                            }
                        }
                    }
                }
                else
                {
                    Hashtable argsHashtable = hashtable["args"] as Hashtable;
                    if (argsHashtable != null)
                    {
                        string msg = argsHashtable["error_msg"].ToString();
                        GameDebug.LogError("GetChannelList error, msg:" + msg);
                    }
                    else
                    {
                        GameDebug.LogError("GetChannelList error, unknown reason");
                    }
                }
            }
        }
Exemplo n.º 22
0
    public void     AdmobAgentReceiveAgentEvent(string json)
    {
        Hashtable  data  = MiniJSON.JsonDecode(json) as Hashtable;
        AdmobEvent eid   = (AdmobEvent)int.Parse(data["eid"].ToString());
        int        iid   = int.Parse(data["iid"].ToString());
        string     error = "";

        if (iid == -1000)
        {
            if (eid == AdmobEvent.OnFailedToReceiveAd)
            {
                error = data["error"].ToString();
            }
            if (OnFullscreenAdEvent != null)
            {
                OnFullscreenAdEvent(eid, error);
            }
        }
        else
        {
            if (handles.ContainsKey(iid))
            {
                HandleAdmobEvent ehandle = handles[iid];
                int width = 0, height = 0;
                if (eid == AdmobEvent.OnReceiveAd)
                {
                    width  = int.Parse(data["width"].ToString());
                    height = int.Parse(data["height"].ToString());
                    banners[iid].AdLoaded = true;
                    banners[iid].Visible  = true;
                }
                if (eid == AdmobEvent.OnFailedToReceiveAd)
                {
                    error = data["error"].ToString();
                    banners[iid].AdLoaded = false;
                    banners[iid].Visible  = false;
                }
                if (ehandle != null)
                {
                    ehandle(eid, width, height, error);
                }
            }
            else
            {
                Debug.LogWarning("Received event without a hanlde (AdmobAgent). IID:" + iid);
            }
        }
    }
Exemplo n.º 23
0
        public void CopyFromCLIOptions(Options opts)
        {
            this.id                      = opts.id;
            this.externalIP              = opts.externalIP;
            this.externalPort            = opts.externalPort;
            this.csIP                    = opts.csIP;
            this.csPort                  = opts.csPort;
            this.shellPort               = opts.shellPort;
            this.reportInterval          = opts.reportInterval;
            this.pingInterval            = opts.pingInterval;
            this.gcLive                  = opts.gcLive;
            this.waitUserCommitSSTimeout = opts.waitUserCommitSSTimeout;
            Hashtable secretDef = ( Hashtable )MiniJSON.JsonDecode(File.ReadAllText(opts.secret));

            this.certPath = secretDef.GetString("certPath");
            this.certPass = secretDef.GetString("certPass");
        }
Exemplo n.º 24
0
        public void CopyFromJson(Hashtable json)
        {
            this.id                      = json.GetUInt("ID");
            this.externalIP              = json.GetString("externalIP");
            this.externalPort            = json.GetInt("externalPort");
            this.csIP                    = json.GetString("csIP");
            this.csPort                  = json.GetInt("csPort");
            this.shellPort               = json.GetInt("shellPort");
            this.reportInterval          = json.GetLong("reportInterval");
            this.pingInterval            = json.GetLong("pingInterval");
            this.gcLive                  = json.GetLong("gcLive");
            this.waitUserCommitSSTimeout = json.GetLong("waitUserCommitSSTimeout");
            Hashtable secretDef = ( Hashtable )MiniJSON.JsonDecode(File.ReadAllText(json.GetString("secret")));

            this.certPath = secretDef.GetString("certPath");
            this.certPass = secretDef.GetString("certPass");
        }
Exemplo n.º 25
0
        public void OnGetServerList(string url, string error, string reply, System.Object userData)
        {
            if (string.IsNullOrEmpty(error) == false)
            {
                GameDebug.LogError("OnGetServerList error: " + error);
                return;
            }

            Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable;

            if (hashtable != null)
            {
                if (DBTextResource.ParseI(hashtable["result"].ToString()) == 1)
                {
                    ArrayList arrayList = hashtable["args"] as ArrayList;
                    if (arrayList != null)
                    {
                        foreach (System.Object o in arrayList)
                        {
                            Hashtable serverInfoHashtable = o as Hashtable;
                            if (serverInfoHashtable != null && serverInfoHashtable.Count > 0)
                            {
                                uint   controlServerId = System.Convert.ToUInt32(serverInfoHashtable["server_id"]);
                                uint   serverId        = System.Convert.ToUInt32(serverInfoHashtable["s_id"]);
                                string name            = System.Convert.ToString(serverInfoHashtable["name"]);

                                SpanServerManager.Instance.AddServerNameFromControlServer(controlServerId, serverId, name);
                            }
                        }
                    }
                }
                else
                {
                    Hashtable argsHashtable = hashtable["args"] as Hashtable;
                    if (argsHashtable != null)
                    {
                        string msg = argsHashtable["error_msg"].ToString();
                        GameDebug.LogError("OnGetServerList error, msg:" + msg);
                    }
                    else
                    {
                        GameDebug.LogError("OnGetServerList error, unknown reason");
                    }
                }
            }
        }
Exemplo n.º 26
0
        public void OnGetPackFinished(string url, string error, string reply, System.Object userData)
        {
            if (string.IsNullOrEmpty(error) == false)
            {
                GameDebug.LogError("OnGetPackFinished error: " + error);
                UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_FAIL"));

                mPostGetPackFinishedCallback?.Invoke(false);
                return;
            }

            bool      ret       = false;
            Hashtable hashtable = MiniJSON.JsonDecode(reply) as Hashtable;

            if (hashtable != null)
            {
                int result = DBTextResource.ParseI(hashtable["result"].ToString());
                if (result == 1)
                {
                    UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_EXCHANGE_SUCCESS"));

                    ret = true;
                }
                else
                {
                    Hashtable argsHashtable = hashtable["args"] as Hashtable;
                    if (argsHashtable != null)
                    {
                        string msg           = argsHashtable["error_msg"].ToString();
                        string translatedMsg = xc.TextHelper.GetTranslateText(msg);
                        UINotice.GetInstance().ShowMessage(translatedMsg);
                    }
                    else
                    {
                        UINotice.GetInstance().ShowMessage(DBConstText.GetText("GIFT_BAG_FAIL"));
                    }
                }
            }
            else
            {
                GameDebug.LogError("OnGetPackFinished error: " + reply);
            }

            mPostGetPackFinishedCallback?.Invoke(ret);
        }
Exemplo n.º 27
0
        public void SystemMessageEx(string param)
        {
            /*{
             *  "action":"PayCallback",
             *  "code":1,  // 1:成功 -1:取消
             *  "msg":"支付成功"
             *
             * }*/

            var json_object = MiniJSON.JsonDecode(param);

            if (json_object == null)
            {
                Debug.LogError("SystemMessageEx: json is invalid");
                return;
            }

            Hashtable param_info = json_object as Hashtable;

            if (param_info == null)
            {
                Debug.LogError("SystemMessageEx: param_info is invalid");
                return;
            }

            string action = param_info["action"].ToString();

            if (action == "PayCallback") // 支付的回调
            {
                int    code = int.Parse(param_info["code"].ToString());
                string msg  = param_info["msg"].ToString();
                if (code == 1)// 成功或者取消的时候才提示
                {
                    UINotice.Instance.ShowMessage(DBConstText.GetText("PAY_NOTICE_SUCC"));
                }
                else if (code == -1)
                {
                    UINotice.Instance.ShowMessage(DBConstText.GetText("PAY_NOTICE_CANCEL"));
                }
                else
                {
                    UINotice.Instance.ShowMessage(DBConstText.GetText("PAY_NOTICE_FAIL"));
                }
            }
        }
Exemplo n.º 28
0
        public Map Load(string file, out string error)
        {
            string text;

            try
            {
                text = System.IO.File.ReadAllText(file);
            }
            catch (Exception e)
            {
                error = e.ToString();
                return(null);
            }
            Map json = ( Map )MiniJSON.JsonDecode(text);

            error = string.Empty;
            return(json);
        }
Exemplo n.º 29
0
    public void     NativeUIReceiveAgentEvent(string json)
    {
        Hashtable     data = MiniJSON.JsonDecode(json) as Hashtable;
        NativeUIEvent e    = (NativeUIEvent)int.Parse(data["eid"].ToString());

        switch (e)
        {
        case NativeUIEvent.InputBoxButton:
            if (input_handle != null)
            {
                int    buttond_index = int.Parse(data["button_index"].ToString());
                string inputstring   = data["input"].ToString();
                input_handle(buttond_index, inputstring);
            }
            break;

        case NativeUIEvent.MessageBoxButton:
            if (msgbox_handle != null)
            {
                msgbox_handle(int.Parse(data["button_index"].ToString()));
            }
            break;

        case NativeUIEvent.PopupMenuButton:
            if (popup_handle != null)
            {
                popup_handle(int.Parse(data["button_index"].ToString()));
            }
            break;

        case NativeUIEvent.MultiplyInputs:
            if (multiply_input != null)
            {
                string[] values = new string[data.Count - 2];
                int      bid    = int.Parse(data["button_index"].ToString());
                for (int i = 0; i < values.Length; i++)
                {
                    values[i] = data["string_" + i].ToString();
                }
                multiply_input(bid, values);
            }
            break;
        }
    }
Exemplo n.º 30
0
        public void CopyFromJson(Hashtable json)
        {
            this.gsID           = json.GetUInt("gsID");
            this.name           = json.GetString("name");
            this.externalIP     = json.GetString("externalIP");
            this.externalPort   = json.GetInt("externalPort");
            this.shellPort      = json.GetInt("shellPort");
            this.password       = json.GetString("password");
            this.maxConnection  = json.GetInt("maxConnection");
            this.csIP           = json.GetString("csIP");
            this.csPort         = json.GetInt("csPort");
            this.reportInterval = json.GetLong("reportInterval");
            this.pingInterval   = json.GetLong("pingInterval");
            this.gcLive         = json.GetLong("gcLive");
            Hashtable secretDef = (Hashtable)MiniJSON.JsonDecode(File.ReadAllText(json.GetString("secret")));

            this.certPath = secretDef.GetString("certPath");
            this.certPass = secretDef.GetString("certPass");
        }