// Запись строки. key = 0 при добавлении и key != 0 при обновлении
        public long Write(long key, string val)
        {
            if (val.Length == 0)
            {
                return(0);
            }

            var tmp = WriteBuffer(key, System.Text.Encoding.Unicode.GetBytes(val));

            // Строка была обновлена
            if (tmp == key)
            {
                cacheString[key] = val;
            }
            // Старая строка была удалена
            else if (key != 0)
            {
                cacheString.Remove(key);
                cacheString.Add(tmp, val);
            }
            // Сстрока была добавлена впервые
            else
            {
                cacheString.Add(tmp, val);
            }

            return(tmp);
        }
        // Запись массива байт. key = 0 при добавлении и key != 0 при обновлении
        public long Write(long key, byte[] val)
        {
            if (val.Length == 0)
            {
                return(0);
            }

            var tmp = WriteBuffer(key, val);

            // Массив был обновлен
            if (tmp == key)
            {
                cacheByte[key] = val;
            }
            // Старый массив был удален
            else if (key != 0)
            {
                cacheByte.Remove(key);
                cacheByte.Add(tmp, val);
            }
            // Массив был добавлен впервые
            else
            {
                cacheByte.Add(tmp, val);
            }

            return(tmp);
        }
Beispiel #3
0
        private static string ValidPermissionInWhiteList(string permission, string openId)
        {
            if (MapWhiteList == null)
            {
                MapWhiteList = new DictionarySafe <string, string[]>();
                MapWhiteList.Add(Permission_Admin, WhiteList_Admin);
                MapWhiteList.Add(Permission_Log, WhiteList_Log);

                //TODO 新的白名单在这里增加
            }

            if (string.IsNullOrEmpty(permission))
            {
                bool valided = (Array.IndexOf(WhiteList_Admin, openId) >= 0);
                if (valided)
                {
                    return(Permission_Admin);
                }

                permission = "";

                foreach (KeyValuePair <string, string[]> pair in MapWhiteList)
                {
                    valided = (Array.IndexOf(pair.Value, openId) >= 0);
                    if (valided)
                    {
                        if (permission == "")
                        {
                            permission = pair.Key;
                        }
                        else
                        {
                            permission = permission + "|" + pair.Key;
                        }
                    }
                }
            }
            else
            {
                bool valided = false;
                if (MapWhiteList.ContainsKey(permission))
                {
                    valided = (Array.IndexOf(MapWhiteList[permission], openId) >= 0);
                }

                if (!valided)
                {
                    permission = "";
                }
            }

            return(permission);
        }
Beispiel #4
0
        public void AddListener <TMsg>(uint cmd, Action <ISession, uint, TMsg> onMsg)
        {
            Debuger.Log("cmd:{0}, listener:{1}.{2}", cmd, onMsg.Method.DeclaringType.Name, onMsg.Method.Name);

            ListenerHelper helper = new ListenerHelper()
            {
                TMsg   = typeof(TMsg),
                onMsg0 = onMsg
            };

            m_listMsgListener.Add(cmd, helper);
        }
Beispiel #5
0
        private void AddServerFrame(FSPFrame frame)
        {
            if (frame.frameId <= 0)
            {
                ExecuteFrame(frame.frameId, frame);
                return;
            }


            frame.frameId      = frame.frameId * m_Param.clientFrameRateMultiple;
            m_LockedFrameIndex = frame.frameId + m_Param.clientFrameRateMultiple - 1;

            m_FrameBuffer.Add(frame.frameId, frame);
            m_FrameCtrl.AddFrameId(frame.frameId);
        }
        public RPCMethodHelper GetMethodHelper(string name)
        {
            var helper = m_mapMethodHelper[name];

            if (helper == null)
            {
                MethodInfo mi       = null;
                object     listener = null;
                for (int i = 0; i < m_listListener.Count; i++)
                {
                    listener = m_listListener[i];
                    mi       = listener.GetType().GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
                    if (mi != null)
                    {
                        break;
                    }
                }

                if (mi != null)
                {
                    helper          = new RPCMethodHelper();
                    helper.listener = listener;
                    helper.method   = mi;
                    m_mapMethodHelper.Add(name, helper);
                }
            }

            return(helper);
        }
Beispiel #7
0
        private static void OnDbgGUI_AnalyseFile(string filename)
        {
            NetDebugFile file = m_mapDbgFile[filename];

            if (file == null)
            {
                file = new NetDebugFile();
                file.Open(NetDebuger.DbgFileDir, filename);
                m_mapDbgFile.Add(filename, file);
            }

            for (int i = 0; i < file.ListAllSampleName.Count; i++)
            {
                string   name  = file.ListAllSampleName[i];
                GUICurve curve = m_mapCurve[filename + ">" + name];

                if (curve == null)
                {
                    curve       = new GUICurve();
                    curve.state = false;
                    m_mapCurve[filename + ">" + name] = curve;
                }

                bool toggle = (bool)curve.state;
                toggle      = GUILayout.Toggle(toggle, name);
                curve.state = toggle;

                if (toggle)
                {
                    OnDbgGUI_ReportFileCurve(curve, file, name);
                }
            }
        }
Beispiel #8
0
        private static void UpdateProfileSampleList()
        {
            List <NetSampleItem> list = NetDebuger.SampleList;
            int totalCnt = list.Count;

            if (m_profileNextIndex > totalCnt)
            {
                m_mapProfileSampleList = new DictionarySafe <string, List <NetSampleItem> >();
                m_mapProfileCurve      = new DictionarySafe <string, GUICurve>();
                m_profileNextIndex     = 0;
            }


            while (m_profileNextIndex < totalCnt)
            {
                NetSampleItem        item     = list[m_profileNextIndex];
                List <NetSampleItem> listTemp = m_mapProfileSampleList[item.name];

                if (listTemp == null)
                {
                    listTemp = new List <NetSampleItem>();
                    m_mapProfileSampleList.Add(item.name, listTemp);

                    GUICurve curve = new GUICurve();
                    curve.state = false;
                    m_mapProfileCurve.Add(item.name, curve);
                }
                listTemp.Add(item);

                m_profileNextIndex++;
            }
        }
        private bool ParserFile()
        {
            m_mapAllSampleList.Clear();
            m_listAllSampleName.Clear();

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

            List <NetSampleItem> listAll = m_content.profiler_samples;

            for (int i = 0; i < listAll.Count; i++)
            {
                NetSampleItem        item = listAll[i];
                List <NetSampleItem> list = m_mapAllSampleList[item.name];
                if (list == null)
                {
                    list = new List <NetSampleItem>();
                    m_mapAllSampleList.Add(item.name, list);
                    m_listAllSampleName.Add(item.name);
                }
                list.Add(item);
            }

            return(true);
        }
Beispiel #10
0
        public void AddListener <TNtf>(uint cmd, Action <TNtf> onNtf)
        {
            Debuger.Log("cmd:{0}, listener:{1}.{2}", cmd, onNtf.Method.DeclaringType.Name, onNtf.Method.Name);

            ListenerHelper helper = new ListenerHelper()
            {
                TMsg  = typeof(TNtf),
                onMsg = onNtf
            };

            m_listNtfListener.Add(cmd, helper);
        }
Beispiel #11
0
        public void Bind(string src, Action <object> handler)
        {
            var binder = m_binders[src];

            if (binder == null)
            {
                var member = GetMemberInfo(src);
                if (member == null)
                {
                    Debuger.LogError("Bind Error, Member Not Exist: {0}", src);
                    return;
                }

                binder = new Binder(this, src, member);
                m_binders.Add(src, binder);
            }
            binder.onValidate.AddListener(handler);
        }