//处理派发过程 把所有的接收到的事件实例派发给其对应的监听器 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); } } } }
//用于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); }
//添加一个事件实例 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); }