protected ChannelEntry?GetChannelDescription(string objectID, string variable) { var channelRef = ChannelRef.Make(objectID, variable); if (cacheChannelEntry.TryGetValue(channelRef, out var mapEnt)) { return(mapEnt); } using (var command = Factory.MakeCommand($"SELECT * FROM channel_defs WHERE obj = @obj AND var = @var", connection !)) { command.Parameters.Add(Factory.MakeParameter("obj", objectID)); command.Parameters.Add(Factory.MakeParameter("var", variable)); using (var reader = command.ExecuteReader()) { if (!reader.Read()) { return(null); } string type = (string)reader["type"]; var chEntry = new ChannelEntry() { Object = objectID, Variable = variable, VarID = (int)reader["varID"], Type = (DataType)Enum.Parse(typeof(DataType), type, ignoreCase: true) }; cacheChannelEntry[channelRef] = chEntry; return(chEntry); } } }
/// <summary> /// 対応する実況IDを探す 対応がなければ0を返す /// </summary> /// <param name="networkId">ネットワークID 不明なら0</param> /// <param name="serviceId">サービスID</param> public int Resolve(ushort networkId, ushort serviceId) { if (networkId == 0) { //録画ファイルではネットワークIDが分からないのでサービスIDだけで検索 //ニコニコ実況に対応しているチャンネルで同じサービスIDのものはないはずなので普通はこれで大丈夫 foreach (ChannelEntry channel in channelDatabase.GetByServiceId(serviceId)) { int jkid = jkIdTable.GetJkId(channel); if (jkid != 0) { return(jkid); } } return(0); } else { ChannelEntry channel = channelDatabase.GetByNetworkIdAndServiceId(networkId, serviceId); if (channel == null) { return(0); } return(jkIdTable.GetJkId(channel)); } }
/// <summary> /// 対応する生放送IDを探す 対応がなければ空文字を返す /// </summary> /// <param name="networkId">ネットワークID 不明なら0</param> /// <param name="serviceId">サービスID</param> public string Resolve(ushort networkId, ushort serviceId) { if (networkId == 0) { //録画ファイルではネットワークIDが分からないのでサービスIDだけで検索 //ニコニコ実況に対応しているチャンネルで同じサービスIDのものはないはずなので普通はこれで大丈夫 foreach (ChannelEntry channel in this.channelDatabase.GetByServiceId(serviceId)) { string liveId = this.liveIdTable.GetLiveId(channel); if (liveId != "") { return(liveId); } } return(""); } else { ChannelEntry channel = this.channelDatabase.GetByNetworkIdAndServiceId(networkId, serviceId); if (channel == null) { return(""); } return(this.liveIdTable.GetLiveId(channel)); } }
/// <summary> /// <paramref name="channel"/>に対応する<see cref="ThreadMappingRuleEntry"/>を返す /// 見つからなければ<c>null</c> /// </summary> public ThreadMappingRuleEntry GetMatchingThreadMappingRuleEntry(ChannelEntry channel) { ThreadMappingRuleEntry ret = null; foreach (ThreadMappingRuleEntry entry in this.ThreadMappingRuleEntries) { switch (entry.Target) { case ThreadMappingRuleTarget.Flags: if (((ChannelFlags)entry.Value & channel.Flags) != 0) { ret = entry; } break; case ThreadMappingRuleTarget.NSId: if (entry.Value == (channel.NetworkId << 16 | channel.ServiceId)) { ret = entry; } break; case ThreadMappingRuleTarget.NId: if (entry.Value == channel.NetworkId) { ret = entry; } break; } } return(ret); }
public ChannelEntry GetOrCreate(string endpoint) { var attempt = 0; while (attempt++ < 2) { lock (_getLock) { var entry = Cache.GetOrCreate(endpoint, cacheEntry => { Log.LogDebug("{CacheId}: Creating a new channel for {Endpoint}", Id, endpoint); cacheEntry.SetOptions(CreateOptions()); var channelAddress = endpoint.Replace("http://", string.Empty); var channel = new Channel(channelAddress, ChannelCredentials.Insecure); var newEntry = new ChannelEntry(channel); Log.LogDebug("{CacheId}: Created new channel for {Endpoint} as {Id}", Id, endpoint, newEntry.Id); return(newEntry); }); if (entry.Invalid) { Cache.Remove(endpoint); } else { return(entry); } } } throw new FabricCannotConnectException($"Failed to connect to {endpoint}"); }
public MatchingThread Resolve(ChannelInfo channelInfo) { ushort networkId = channelInfo.NetworkId, serviceId = channelInfo.ServiceId; if (networkId == 0) { //録画ファイルなどではネットワークIDが分からないのでサービスIDだけで検索 //BSとCSの間ではサービスIDが重複する可能性があるがほとんどないので割り切る foreach (ChannelEntry channel in channelDatabase.GetByServiceId(serviceId)) { MatchingThread ret = boardDatabase.GetMatchingThreadForChannel(channel); if (ret != null) { return(ret); } } return(null); } else { ChannelEntry channel = channelDatabase.GetByNetworkIdAndServiceId(networkId, serviceId);//channels.txtの登録チャンネルに解決 if (channel == null) { return(null); } return(boardDatabase.GetMatchingThreadForChannel(channel)); } }
/// <summary> /// Add new channel. /// </summary> /// <param name="channel">channel</param> /// <param name="eventHandler">channel handler</param> public void Add(ISSHChannel channel, ISSHChannelEventHandler eventHandler) { uint channelNumber = channel.LocalChannel; var entry = new ChannelEntry(channel, eventHandler); _dic.TryAdd(channelNumber, entry); #if DEBUG_REPORT_SSHCHANNELS Debug.WriteLine("** CHANNEL ADD " + channelNumber.ToString() + " { " + String.Join(", ", _dic.Keys.OrderBy(n => n).Select(n => n.ToString())) + " }"); #endif }
protected ChannelEntry FindChannelEntry(int id) { for (int i = 0; i < _channel_entries.Count; i++) { ChannelEntry e = (ChannelEntry)_channel_entries[i]; if (e._localID == id) { return(e); } } return(null); }
public static void addToBackToTheGrave(ChannelEntry entry) { if (entry.channel_type.isOf(ChannelType.BackToTheGrave)) { if (back_to_the_grave_base == null) { back_to_the_grave_base = entry.base_ability; } else { back_to_the_grave_base.addToAbilityVariants(entry.ability); } } }
public MatchingThread Resolve(ChannelInfo channelInfo, bool ignoreMainThreadTitleKeywords) { MatchingThread getMatchingThread(ChannelEntry channel) { if (!ignoreMainThreadTitleKeywords) { return(this.boardDatabase.GetMatchingThread(channel)); } else { ThreadMappingRuleEntry ruleEntry = this.boardDatabase.GetMatchingThreadMappingRuleEntry(channel); if (ruleEntry == null) { return(null); } BoardEntry boardEntry = this.boardDatabase.GetBoardEntryById(ruleEntry.BoardId); if (boardEntry == null) { return(null); } return(new MatchingThread(boardEntry.Title, boardEntry.Uri, ruleEntry.ThreadTitleKeywords)); } } ushort networkId = channelInfo.NetworkId, serviceId = channelInfo.ServiceId; if (networkId == 0) { //録画ファイルなどではネットワークIDが分からないのでサービスIDだけで検索 //BSとCSの間ではサービスIDが重複する可能性があるがほとんどないので割り切る foreach (ChannelEntry channel in channelDatabase.GetByServiceId(serviceId)) { MatchingThread ret = getMatchingThread(channel); if (ret != null) { return(ret); } } return(null); } else { ChannelEntry channel = channelDatabase.GetByNetworkIdAndServiceId(networkId, serviceId);//channels.txtの登録チャンネルに解決 if (channel == null) { return(null); } return(getMatchingThread(channel)); } }
static void addToChannelingScourge(ChannelEntry c) { if (channeling_scourge == null) { return; } var cleric = library.Get <BlueprintCharacterClass>("67819271767a9dd4fbfd4ae700befea0"); if (c.channel_type.isOf(ChannelType.Harm) && c.channel_type.isNotOf(ChannelType.BackToTheGrave) && c.scalesWithClass(cleric)) { var components = channeling_scourge.GetComponents <NewMechanics.ContextIncreaseCasterLevelForSelectedSpells>(); foreach (var component in components) { component.spells = component.spells.AddToArray(c.ability); } } }
private async Task HandleEvicted(ChannelEntry value, EvictionReason reason) { var target = value.Channel.Target; Log.LogInformation("Evicted {Address} due to {Reason}", target, reason); try { await PerformEvictionActions(value).ConfigureAwait(false); Log.LogInformation("Evicted ok for {Address} due to {Reason}", target, reason); } catch (Exception ex) { Log.LogError(ex, "Error evicting {Address} due to {Reason}: {Exception}", target, reason, ex.Message); } }
void OnChannelList(Packet response, BinaryReader reader, IPEndPoint source) { AllActiveChannels.Clear(); int count = reader.ReadInt32(); for (int i = 0; i < count; ++i) { ChannelEntry _newChannelEntry = new ChannelEntry(); _newChannelEntry.id = reader.ReadInt32(); _newChannelEntry.count = reader.ReadUInt16(); _newChannelEntry.limit = reader.ReadUInt16(); _newChannelEntry.password = reader.ReadBoolean(); _newChannelEntry.persistent = reader.ReadBoolean(); _newChannelEntry.level = reader.ReadString(); _newChannelEntry.data = reader.ReadString(); AllActiveChannels.Add(_newChannelEntry); } }
static void addToImprovedChannel(ChannelEntry c) { if (improved_channel == null) { return; } var prereq = improved_channel.GetComponent <PrerequisiteFeaturesFromList>(); if (!prereq.Features.Contains(c.parent_feature)) { prereq.Features = prereq.Features.AddToArray(c.parent_feature); } var abilities = improved_channel.GetComponent <NewMechanics.IncreaseSpecifiedSpellsDC>(); if (!abilities.spells.Contains(c.ability)) { abilities.spells = abilities.spells.AddToArray(c.ability); } }
public static bool ValidateChannel(ChannelEntry channelEntry) { if (channelEntry.Invalid) { return(false); } else { var channel = channelEntry.Channel; switch (channel.State) { case ChannelState.Shutdown: case ChannelState.TransientFailure: return(false); default: return(true); } } }
protected ChannelEntry RegisterChannelEventReceiver(SSHChannel ch, ISSHChannelEventReceiver r) { lock (this) { ChannelEntry e = new ChannelEntry(); e._channel = ch; e._receiver = r; e._localID = _channel_sequence++; for (int i = 0; i < _channel_entries.Count; i++) { if (_channel_entries[i] == null) { _channel_entries[i] = e; return(e); } } _channel_entries.Add(e); return(e); } }
/// <summary> /// 対応する板IDとスレッドタイトルを返す 対応がなければnull /// </summary> /// <returns>対応する板IDとスレッドタイトル スレッドタイトルはnullの可能性もある</returns> public BoardIdAndThreadTitleKeywords Get(ChannelEntry channel) { string boardId = null; string[] threadTitle = null; foreach (ThreadMappingRuleEntry rule in rules) { switch (rule.Target) { case ThreadMappingRuleTarget.Flags: if (((ChannelFlags)rule.Value & channel.Flags) != 0) { boardId = rule.BoardId; threadTitle = rule.ThreadTitleKeywords; } break; case ThreadMappingRuleTarget.NSId: if (rule.Value == (channel.NetworkId << 16 | channel.ServiceId)) { boardId = rule.BoardId; threadTitle = rule.ThreadTitleKeywords; } break; case ThreadMappingRuleTarget.NId: if (rule.Value == channel.NetworkId) { boardId = rule.BoardId; threadTitle = rule.ThreadTitleKeywords; } break; } } if (boardId == null) { return(null); } return(new BoardIdAndThreadTitleKeywords(boardId, threadTitle)); }
public static void storeChannel(BlueprintAbility ability, BlueprintFeature parent_feature, ChannelType channel_type) { var entry = new ChannelEntry(ability, parent_feature, channel_type); channel_entires.Add(entry); addToImprovedChannel(entry); addToChannelingScourge(entry); addToWitchImprovedChannelHexScaling(entry); addToQuickChannel(entry); addToChannelSmite(entry); addToImprovedChannel(entry); Common.addFeaturePrerequisiteOr(selective_channel, parent_feature); addToBackToTheGrave(entry); addToVersatileChanneler(entry); }
static void addToWitchImprovedChannelHexScaling(ChannelEntry entry) { if (witch_channel_negative == null) { return; } if (!entry.scalesWithClass(Witch.witch_class)) { return; } if ((entry.channel_type & ChannelType.Negative) != ChannelType.None) { var comp = witch_channel_negative.GetComponent <NewMechanics.ContextIncreaseCasterLevelForSelectedSpells>(); comp.spells = comp.spells.AddToArray(entry.ability); } if ((entry.channel_type & ChannelType.Positive) != ChannelType.None) { var comp = witch_channel_positive.GetComponent <NewMechanics.ContextIncreaseCasterLevelForSelectedSpells>(); comp.spells = comp.spells.AddToArray(entry.ability); } }
/// <summary> /// 対応する生放送IDを返す(対応がなければ空文字) /// </summary> public string GetLiveId(ChannelEntry channel) { string ret; if (this.tableCache.TryGetValue(channel, out ret)) { return(ret); } ret = ""; foreach (Tuple <RuleTarget, uint, string> rule in this.rules) { switch (rule.Item1) { case RuleTarget.Flags: if ((channel.Flags & (ChannelFlags)rule.Item2) != 0) { ret = rule.Item3; } break; case RuleTarget.NSId: if (channel.NetworkId == (rule.Item2 >> 16) && channel.ServiceId == (rule.Item2 & 0xFFFF)) { ret = rule.Item3; } break; case RuleTarget.NId: if (channel.NetworkId == rule.Item2) { ret = rule.Item3; } break; } } this.tableCache.Add(channel, ret); return(ret); }
/// <summary> /// <paramref name="channel"/>に対応する板とスレッド名キーワードを返す /// 見つからなければ<c>null</c> /// </summary> public MatchingThread GetMatchingThread(ChannelEntry channel) { string[] threadTitleKeywords; var boardAndThread = this.GetMatchingThreadMappingRuleEntry(channel);//板名とスレッドタイトルを得る if (boardAndThread == null) { return(null); } BoardEntry board = this.GetBoardEntryById(boardAndThread.BoardId);//板名から板URLと主要スレッド名を得る if (board == null) { return(null); } threadTitleKeywords = boardAndThread.ThreadTitleKeywords ?? board.MainThreadTitleKeywords; if (threadTitleKeywords == null) { return(null); } return(new MatchingThread(board.Title, board.Uri, threadTitleKeywords)); }
static void addToVersatileChanneler(ChannelEntry entry) { if (versatile_channeler == null) { return; } var cleric = library.Get <BlueprintCharacterClass>("67819271767a9dd4fbfd4ae700befea0"); if (entry.scalesWithClass(cleric)) { if (entry.channel_type.isOf(ChannelType.Positive)) { var comp = versatile_channeler_positive.GetComponent <NewMechanics.ContextIncreaseCasterLevelForSelectedSpells>(); comp.spells = comp.spells.AddToArray(entry.ability); } else if (entry.channel_type.isOf(ChannelType.Negative)) { var comp = versatile_channeler_negative.GetComponent <NewMechanics.ContextIncreaseCasterLevelForSelectedSpells>(); comp.spells = comp.spells.AddToArray(entry.ability); } } if (entry.scalesWithClass(Warpriest.warpriest_class)) { if (entry.channel_type.isOf(ChannelType.Positive)) { var comp = versatile_channeler_positive_warpriest.GetComponent <NewMechanics.ContextIncreaseCasterLevelForSelectedSpells>(); comp.spells = comp.spells.AddToArray(entry.ability); } else if (entry.channel_type.isOf(ChannelType.Negative)) { var comp = versatile_channeler_negative_warpriest.GetComponent <NewMechanics.ContextIncreaseCasterLevelForSelectedSpells>(); comp.spells = comp.spells.AddToArray(entry.ability); } } }
static void addToQuickChannel(ChannelEntry entry) { if (quick_channel == null) { return; } if (entry.ability.ActionType != Kingmaker.UnitLogic.Commands.Base.UnitCommand.CommandType.Standard) { return; } Common.addFeaturePrerequisiteOr(quick_channel, entry.parent_feature); var quicken_ability = library.CopyAndAdd <BlueprintAbility>(entry.ability.AssetGuid, "Quick" + entry.ability.name, entry.ability.AssetGuid, "e936d73a1dfe42efb1765b980c80e113"); quicken_ability.ActionType = Kingmaker.UnitLogic.Commands.Base.UnitCommand.CommandType.Move; quicken_ability.SetName(quicken_ability.Name + $" ({quick_channel.Name})"); var resource_logic = quicken_ability.GetComponent <AbilityResourceLogic>(); var amount = resource_logic.Amount; quicken_ability.ReplaceComponent <AbilityResourceLogic>(c => { c.Amount = amount * 2; }); quicken_ability.AddComponent(Common.createAbilityShowIfCasterHasFact(quick_channel)); entry.base_ability.addToAbilityVariants(quicken_ability); updateItemsForChannelDerivative(entry.ability, quicken_ability); var quicken_feature = Common.AbilityToFeature(quicken_ability, guid: Helpers.MergeIds(quicken_ability.AssetGuid, entry.parent_feature.AssetGuid)); quicken_feature.ComponentsArray = new BlueprintComponent[0]; storeChannel(quicken_ability, quicken_feature, entry.channel_type | ChannelType.Quick); normal_quick_channel_map.Add(entry.ability.AssetGuid, quicken_ability.AssetGuid); }
protected ChannelEntry?GetChannelDescription(string objectID, string variable) { var channelRef = ChannelRef.Make(objectID, variable); if (cacheChannelEntry.TryGetValue(channelRef, out var mapEnt)) { return(mapEnt); } var stmtSelectChannel = this.stmtSelectChannel; if (stmtSelectChannel == null) { return(null); } stmtSelectChannel[0] = objectID; stmtSelectChannel[1] = variable; using (var reader = stmtSelectChannel.ExecuteReader()) { if (!reader.Read()) { return(null); } string type = (string)reader["type"]; ChannelEntry chEntry = new ChannelEntry() { Object = objectID, Variable = variable, DataTableName = (string)reader["table_name"], Type = (DataType)Enum.Parse(typeof(DataType), type, ignoreCase: true) }; cacheChannelEntry[channelRef] = chEntry; return(chEntry); } }
static void addToChannelSmite(ChannelEntry c) { if (channel_smite == null) { return; } if (!(c.channel_type.isOf(ChannelType.Harm) && c.channel_type.isBase())) { return; } Common.addFeaturePrerequisiteOr(channel_smite, c.parent_feature); var resounding_blow = library.Get <BlueprintAbility>("9047cb1797639924487ec0ad566a3fea"); var smite_evil = library.Get <BlueprintAbility>("7bb9eb2042e67bf489ccd1374423cdec"); var buff = Helpers.CreateBuff("ChannelSmite" + c.ability.name + "Buff", $"Channel Smite ({c.ability.Name})", channel_smite.Description, Helpers.MergeIds(c.ability.AssetGuid, "0d406cf592524c85b796216ed4ee3ab3"), resounding_blow.Icon, null, Common.createAddInitiatorAttackWithWeaponTrigger(c.ability.GetComponent <AbilityEffectRunAction>().Actions, check_weapon_range_type: true), Common.createAddInitiatorAttackWithWeaponTrigger(Helpers.CreateActionList(Helpers.Create <ContextActionRemoveSelf>()), check_weapon_range_type: true, only_hit: false, on_initiator: true), c.ability.GetComponent <ContextRankConfig>() ); var apply_buff = Common.createContextActionApplyBuff(buff, Helpers.CreateContextDuration(Common.createSimpleContextValue(1), Kingmaker.UnitLogic.Mechanics.DurationRate.Rounds), dispellable: false ); var ability = Helpers.CreateAbility("ChannelSmite" + c.ability.name, buff.Name, buff.Description, Helpers.MergeIds(c.ability.AssetGuid, "81e5fc81f1a644d5898a9fdbda752e95"), buff.Icon, AbilityType.Supernatural, Kingmaker.UnitLogic.Commands.Base.UnitCommand.CommandType.Swift, AbilityRange.Personal, Helpers.oneRoundDuration, c.ability.LocalizedSavingThrow, smite_evil.GetComponent <AbilitySpawnFx>(), c.ability.GetComponent <AbilityResourceLogic>(), Helpers.CreateRunActions(apply_buff), c.ability.GetComponent <ContextRankConfig>(), c.ability.GetComponent <NewMechanics.ContextCalculateAbilityParamsBasedOnClasses>(), Common.createAbilityShowIfCasterHasFact(channel_smite) ); ability.setMiscAbilityParametersSelfOnly(); c.base_ability.addToAbilityVariants(ability); updateItemsForChannelDerivative(c.ability, ability); var caster_alignment = c.ability.GetComponent <AbilityCasterAlignment>(); if (caster_alignment != null) { ability.AddComponent(caster_alignment); } var smite_feature = Common.AbilityToFeature(ability, guid: Helpers.MergeIds(ability.AssetGuid, c.parent_feature.AssetGuid)); smite_feature.ComponentsArray = new BlueprintComponent[0]; normal_smite_map.Add(c.ability.AssetGuid, ability.AssetGuid); storeChannel(ability, c.parent_feature, c.channel_type | ChannelType.Smite); }
private Task PerformEvictionActions(ChannelEntry value) { Log.LogDebug("Shutting down channel {Id} for {Address}, {State}", value.Id, value.Channel.Target, value.Channel.State); return(value.ShutdownAsync()); }
protected ChannelEntry RegisterChannelEventReceiver(SSHChannel ch, ISSHChannelEventReceiver r) { lock(this) { ChannelEntry e = new ChannelEntry(); e._channel = ch; e._receiver = r; e._localID = _channel_sequence++; for(int i=0; i<_channel_entries.Count; i++) { if(_channel_entries[i]==null) { _channel_entries[i] = e; return e; } } _channel_entries.Add(e); return e; } }
internal GrpcCommunicationClient(string connectionAddress, ChannelEntry channelEntry, TClient client) { Client = client; ChannelEntry = channelEntry; ConnectionAddress = connectionAddress; }