コード例 #1
0
        //从FduClusterCommandDispatcher中获取一次数据
        public void RefreshData()
        {
            if (!isRunnig || ClusterHelper.Instance == null)
            {
                return;
            }

            List <ClusterCommand> .Enumerator Commands = FduClusterCommandDispatcher.getCommands();
            while (Commands.MoveNext())
            {
                if (_CommandQueue.Count >= MAX_Command_COUNT)
                {
                    _CommandQueue.Dequeue();
                }

                if (_CommandAccumulatedTimes.ContainsKey(Commands.Current.getCommandName()))
                {
                    _CommandAccumulatedTimes[Commands.Current.getCommandName()]++;
                }
                else
                {
                    _CommandAccumulatedTimes[Commands.Current.getCommandName()] = 0;
                }

                _CommandQueue.Enqueue(new ClusterCommandShowData(ClusterCommand.createSnapShot(Commands.Current), ClusterHelper.Instance.FrameCount));
            }
        }
コード例 #2
0
        static public ClusterCommand create(string CommandName, params object[] parameters)
        {
            ClusterCommand newCommand = new ClusterCommand(CommandName);

            newCommand.addParameters(parameters);
            return(newCommand);
        }
コード例 #3
0
 //处理派发过程 把所有的接收到的事件实例派发给其对应的监听器
 static void processDispatch()
 {
     List <ClusterCommand> .Enumerator CommandNumerator = _clusterCommandMgr.getUnprocessedCommands();
     while (CommandNumerator.MoveNext())
     {
         ClusterCommand _Command = CommandNumerator.Current;
         if (_CommandExecutorMap.ContainsKey(_Command.getCommandName()))
         {
             Dictionary <uint, Action <ClusterCommand> > .Enumerator dicNumerator = _CommandExecutorMap[_Command.getCommandName()].ActionMap.GetEnumerator();
             while (dicNumerator.MoveNext())
             {
                 dicNumerator.Current.Value(_Command);
             }
         }
     }
 }
コード例 #4
0
        //添加一个事件实例
        public void addClusterCommand(ClusterCommand clusterCommand, bool multiCommandAllow = true)
        {
            if (ClusterHelper.Instance.Client != null)
            {
                return;                    //Slave node can not raise cluster Command
            }
            if (clusterCommand == null)
            {
                Debug.LogError("[ClusterCommand]ClusterCommand instance can not be null");
                return;
            }

            if (!multiCommandAllow)
            {
                var result = _clusterCommandWatingList.Find((e) => { return(e.getCommandName().Equals(clusterCommand.getCommandName())); });
                if (result != null)
                {
                    return;
                }
            }
            _clusterCommandWatingList.Add(clusterCommand);
        }
コード例 #5
0
        public override NetworkState.NETWORK_STATE_TYPE Deserialize()
        {
            NetworkState.NETWORK_STATE_TYPE state = NetworkState.NETWORK_STATE_TYPE.SUCCESS;
            clearClusterCommands();
            int CommandCount = BufferedNetworkUtilsClient.ReadInt(ref state); //total number of cluster Commands

            try
            {
                for (int i = 0; i < CommandCount; ++i)
                {
                    ClusterCommand newCommand = new ClusterCommand("1");
                    newCommand.DeserializeParameterData(ref state);
                    newCommand.DeserializeGenericData(ref state);
                    _clusterCommandWatingList.Add(newCommand);
                }
                ClusterCommandStatisticClass.instance.RefreshData();
                FduClusterCommandDispatcher.NotifyDispatch();
            }
            catch (InvalidSendableDataException e)
            {
                Debug.LogError(e.Message);
            }
            return(state);
        }
コード例 #6
0
        //用于Debug工具中 游览事件信息 为该事件创建快照并保存起来
        static public ClusterCommand createSnapShot(ClusterCommand e)
        {
            if (e != null)
            {
                ClusterCommand newCommand = new ClusterCommand(e.getCommandName());
                var            enu        = e._paraMap.GetEnumerator();
                while (enu.MoveNext())
                {
                    newCommand._paraMap.Add(enu.Current.Key, enu.Current.Value.ToString());
                }

                var collEnu = e._genericMap.GetEnumerator();
                while (collEnu.MoveNext())
                {
                    var ins = new genericData();
                    ins.containerTypeName = collEnu.Current.Value.containerTypeName;
                    ins.keyTypeName       = collEnu.Current.Value.keyTypeName;
                    ins.valueTypeName     = collEnu.Current.Value.valueTypeName;
                    newCommand._genericMap.Add(collEnu.Current.Key, ins);
                }
                return(newCommand);
            }
            return(null);
        }
コード例 #7
0
 void onReceiveCommand(ClusterCommand e)
 {
     trigger = true;
 }
コード例 #8
0
 public ClusterCommandShowData(ClusterCommand ce, int frame)
 {
     e          = ce;
     frameCount = frame;
 }
コード例 #9
0
        static public ClusterCommand create(string CommandName)
        {
            ClusterCommand newCommand = new ClusterCommand(CommandName);

            return(newCommand);
        }
コード例 #10
0
 /// <summary>
 ///Send ClusterCommand with a cluster Command instance
 /// </summary>
 /// <param name="clusterCommand">Command Instance</param>
 /// <param name="multiCommandAllow">Whether multi Command instances with the same Command Name can be raised.Default value is true.</param>
 static public void SendClusterCommand(ClusterCommand clusterCommand, bool multiCommandAllow = true)
 {
     _clusterCommandMgr.addClusterCommand(clusterCommand, multiCommandAllow);
 }
コード例 #11
0
 /// <summary>
 /// Send Cluster Command with Command parameters and Command name
 /// </summary>
 /// <param name="CommandName">Name of the Command name</param>
 /// <param name="multiCommandAllow">Whether multi Command instances with the same Command Name can be raised.Default value is true.</param>
 /// <param name="paras">The first element of each Name-Value Pair must be string which is the name of the parameter,then follow the parameter value e.g. RaiseClusterCommand("CommandName",true,"paraName1",1.0f,"paraName2",2.0f)</param>
 static public void SendClusterCommand(string CommandName, bool multiCommandAllow, params object[] paras)
 {
     _clusterCommandMgr.addClusterCommand(ClusterCommand.create(CommandName, paras), multiCommandAllow);
 }
コード例 #12
0
 /// <summary>
 ///Send Cluster Command with Command parameters and Command name
 /// </summary>
 /// <param name="CommandName">Name of the Command name</param>
 /// <param name="paras">The first element of each Name-Value Pair must be string which is the name of the parameter,then follow the parameter value e.g. RaiseClusterCommand("CommandName","paraName1",1.0f,"paraName2",2.0f)</param>
 static public void SendClusterCommand(string CommandName, params object[] paras)
 {
     _clusterCommandMgr.addClusterCommand(ClusterCommand.create(CommandName, paras));
 }