public PathQuery(Vector3 from, Vector3 to, IContextHandler contextHandler, Action<PathQuery> callback) { this.from = from; this.to = to; m_ContextHandler = contextHandler; this.callback = callback; }
public static void CreateInstance(IContextHandler contextHandler) { Debug.Assert(contextHandler != null, "contextHandler is null"); Debug.Assert(_contextHandler == null, "ContextInstance exists already. Call CreateInstance only at startup."); _contextHandler = contextHandler; }
public void SendMailList() { if (firstCheckSinceLogin) { ServerApp <RealmServer> .IOQueue.AddMessage(new Message(() => { Load(); IContextHandler contextHandler = m_chr.ContextHandler; if (contextHandler == null) { return; } contextHandler.AddMessage(() => { if (m_chr == null || !m_chr.IsInWorld) { return; } SendMailList(); }); })); firstCheckSinceLogin = false; } else { MailHandler.SendMailList(m_chr.Client, CollectMail()); } }
/// <summary> /// Adds the Item to the given slot without any further checks. /// Make sure all parameters are valid (eg by calling <code>CheckAdd</code> beforehand) /// or use <code>TryAdd</code> instead. /// </summary> /// <param name="slot"></param> /// <param name="item"></param> public void AddUnchecked(int slot, Item item, bool isNew) { this[slot] = item; if (isNew) { this.OwnerInventory.OnNewStack(item); } else { Character owner = this.Owner; IContextHandler contextHandler = owner.ContextHandler; if (contextHandler == null) { return; } contextHandler.AddMessage((Action)(() => { if (!owner.IsInWorld) { return; } owner.AddItemToUpdate(item); })); } }
public WMSProxyMiddleware(RequestDelegate next, IOptions <WMSProxyOptions> wmsProxyOptions, IContextHandler contextHandler, IWMSProxyManager wmsProxyManager) { _contextHandler = contextHandler ?? throw new ArgumentNullException(nameof(contextHandler)); _next = next ?? throw new ArgumentNullException(nameof(next)); _wmsProxyOptions = wmsProxyOptions?.Value ?? throw new ArgumentNullException(nameof(wmsProxyOptions)); _wmsProxyManager = wmsProxyManager ?? throw new ArgumentNullException(nameof(wmsProxyManager)); }
public WMSProxyManager(IWMSProxyRequestHandler wmsProxyRequestHandler, IWMSProxy wmsProxy, ILogger logger, IContextHandler contextHandler) { _wmsProxyRequestHandler = wmsProxyRequestHandler ?? throw new ArgumentNullException(nameof(wmsProxyRequestHandler)); _wmsProxy = wmsProxy ?? throw new ArgumentNullException(nameof(wmsProxy)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _contextHandler = contextHandler ?? throw new ArgumentNullException(nameof(contextHandler)); }
public void SendMailList() { if (this.firstCheckSinceLogin) { ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((IMessage) new Message((Action)(() => { this.Load(); IContextHandler contextHandler = this.m_chr.ContextHandler; if (contextHandler == null) { return; } contextHandler.AddMessage((Action)(() => { if (this.m_chr == null || !this.m_chr.IsInWorld) { return; } this.SendMailList(); })); }))); this.firstCheckSinceLogin = false; } else { MailHandler.SendMailList((IPacketReceiver)this.m_chr.Client, (IList <MailMessage>) this.CollectMail()); } }
public PathQuery(Vector3 from, Vector3 to, IContextHandler contextHandler, PathQueryCallback callback) { this.from = from; this.to = to; m_ContextHandler = contextHandler; this.callback = callback; Path = new Path(); }
public PathQuery(Vector3 from, Vector3 to, IContextHandler contextHandler, PathQuery.PathQueryCallback callback) { this.from = from; this.to = to; this.m_ContextHandler = contextHandler; this.callback = callback; this.Path = new Path(); }
public static void InitWebReader() { WebContext = ContextHandler.Instance; IReadOnlyList <string> myreaders = WebContext.ListReaders(); string readername = myreaders[0]; WebReader = new SmartCardReader(readername); }
public async Task <object> Invoke(object input) { WebContext = ContextHandler.Instance; IReadOnlyList <string> myreaders = WebContext.ListReaders(); string readername = myreaders[0]; WebReader = new SmartCardReader(readername); return(WebReader.PcscReaderName); }
/// <summary> /// Initializes a new instance of the <see cref="DecisionController"/> class. /// </summary> /// <param name="contextHandler">The Context handler</param> /// <param name="delegationContextHandler">The delegation context handler</param> /// <param name="policyRetrievalPoint">The policy Retrieval point</param> /// <param name="delegationRepository">The delegation repository</param> /// <param name="logger">the logger.</param> public DecisionController(IContextHandler contextHandler, IDelegationContextHandler delegationContextHandler, IPolicyRetrievalPoint policyRetrievalPoint, IDelegationMetadataRepository delegationRepository, ILogger <DecisionController> logger) { _pdp = new PolicyDecisionPoint(); _prp = policyRetrievalPoint; _contextHandler = contextHandler; _delegationContextHandler = delegationContextHandler; _delegationRepository = delegationRepository; _logger = logger; }
/// <summary> /// Executes the given callback immediately for every online group member in the given context. /// IMPORTANT: Must be called from within context. /// </summary> public void CallOnAllInSameContext(IContextHandler context, Action <Character> callback) { context.EnsureContext(); foreach (Character allCharacter in GetAllCharacters()) { if (allCharacter.ContextHandler == context) { callback(allCharacter); } } }
protected virtual IQueryable ValidateQuery(ActionContext actionContext, IQueryable queryable, int?takeCount, IBeetleService service, IContextHandler contextHandler) { var maxResultCount = actionContext.MaxResultCount ?? service?.MaxResultCount; if (maxResultCount > 0 && (takeCount == null || takeCount > maxResultCount)) { var count = Queryable.Count((dynamic)queryable); if (count > maxResultCount) { throw new BeetleException(Resources.ResultCountExceeded); } } return(queryable); }
/// <summary> /// Attempts to handle an incoming packet. /// Constraints: OpCode must be valid. /// GamePackets cannot be sent if ActiveCharacter == null or Account == null. /// The packet is disposed after being handled. /// </summary> /// <param name="client">the client the packet is from</param> /// <param name="packet">the packet to be handled</param> /// <returns>true if the packet could be handled or false otherwise</returns> public override bool HandlePacket(IRealmClient client, RealmPacketIn packet) { bool flag = true; try { if (packet.PacketId.RawId == 1000U) { return(true); } PacketHandler <IRealmClient, RealmPacketIn> handlerDesc = this.m_handlers.Get <PacketHandler <IRealmClient, RealmPacketIn> >(packet.PacketId.RawId); try { if (handlerDesc == null) { this.HandleUnhandledPacket(client, packet); return(true); } IContextHandler contextHandler = this.CheckConstraints(client, handlerDesc, packet); if (contextHandler == null) { return(false); } contextHandler.AddMessage((IMessage) new PacketMessage(handlerDesc.Handler, client, packet)); flag = false; return(true); } catch (Exception ex) { LogUtil.ErrorException(ex, WCell_RealmServer.PacketHandleException, new object[2] { (object)client, (object)packet.PacketId }); return(false); } } finally { if (flag) { packet.Close(); } } }
/// <summary> /// Lets the given ContextHandler wait one Tick. Does nothing if within the given Handler's Context. /// </summary> /// <param name="contextHandler"></param> public static void WaitOne(this IContextHandler contextHandler) { object obj = new object(); if (contextHandler.IsInContext) { return; } lock (obj) { contextHandler.AddMessage(() => { lock (obj) Monitor.PulseAll(obj); }); Monitor.Wait(obj); } }
private static void LoadItemCharRelations() { foreach (Character allCharacter in World.GetAllCharacters()) { IContextHandler contextHandler = allCharacter.ContextHandler; if (contextHandler != null) { Character character = allCharacter; contextHandler.AddMessage(() => { if (!character.IsInWorld) { return; } character.InitItems(); }); } } }
/// <summary> /// Lets the given ContextHandler wait one Tick. Does nothing if within the given Handler's Context. /// </summary> /// <param name="contextHandler"></param> public static void WaitOne(this IContextHandler contextHandler) { var obj = new Object(); if (!contextHandler.IsInContext) { lock (obj) { contextHandler.AddMessage(() => { lock (obj) { Monitor.PulseAll(obj); } }); Monitor.Wait(obj); } } }
public override void ClearCooldowns() { IContextHandler contextHandler = Owner.ContextHandler; if (contextHandler == null) { return; } contextHandler.AddMessage(() => { if (m_cooldowns == null) { return; } foreach (CooldownRemoveTimer cooldown in m_cooldowns) { Owner.RemoveUpdateAction(cooldown); AddReadySpell(cooldown.Spell); } }); }
public override void ClearCooldowns() { IContextHandler contextHandler = this.Owner.ContextHandler; if (contextHandler == null) { return; } contextHandler.AddMessage((Action)(() => { if (this.m_cooldowns == null) { return; } foreach (NPCSpellCollection.CooldownRemoveTimer cooldown in this.m_cooldowns) { this.Owner.RemoveUpdateAction((ObjectUpdateTimer)cooldown); this.AddReadySpell(cooldown.Spell); } })); }
/// <summary> /// Tells the AuthServer to change the role for this Account. /// </summary> /// <param name="role">the new role for this account</param> /// <returns>true if the role was set; false otherwise</returns> /// <remarks>Requires IO-Context</remarks> public bool SetRole(RoleGroup role) { bool wasStaff = this.Role.IsStaff; if (!this.Role.Equals((object)role)) { this.Role = role; if (wasStaff != role.IsStaff) { Character chr = this.ActiveCharacter; if (chr != null) { Map map = chr.Map; IContextHandler context = chr.ContextHandler; if (context != null) { context.AddMessage((Action)(() => { if (!chr.IsInWorld || chr.Map != context) { return; } if (wasStaff) { --World.StaffMemberCount; map.IncreasePlayerCount(chr); } else { ++World.StaffMemberCount; map.DecreasePlayerCount(chr); } })); } } } } return(true); }
public override void Dispatch(WorldClient client, Stump.DofusProtocol.Messages.Message message) { if (message is BasicPingMessage) { client.Send(new BasicPongMessage((message as BasicPingMessage).quiet)); } else { List <MessageHandler> Handlers; if (this.m_handlers.TryGetValue(message.MessageId, out Handlers)) { if (!Handlers.Any(entry => entry.Container.CanHandleMessage(client, message.MessageId))) { this.m_logger.Warn(string.Concat(new object[] { client, " tried to send ", message, " but predicate didn't success" })); } else { IContextHandler contextHandler = this.GetContextHandler(Handlers.First().Attribute, client, message); if (contextHandler != null) { foreach (var handler in Handlers) { contextHandler.AddMessage(new HandledMessage <WorldClient>(handler.Action, client, message)); } } } } else { this.m_logger.Debug("Received Unknown packet : " + message); } } }
public UDPClient(bool sim, int port, ClientEndPoint c, ClientState cs, IContextHandler cb) { // socket = new UdpClient(port); socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); // socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); // socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); // socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, false); if (sim) { socket.Bind(new IPEndPoint(IPAddress.Any, port)); } else { socket.Bind(new IPEndPoint(IPAddress.Any, 1888)); } contextHandler = cb; remoteEndPoint = c; clientState = cs; }
public DefaultInterceptor(Func<CallHookArgs, IEnumerable<ICallHook>> hooks, IContextHandler headerHandler, bool client) { Hooks = hooks; Client = client; HeaderHandler = headerHandler; }
/// <summary> /// Executes the given callback immediately for every online group member in the given context. /// IMPORTANT: Must be called from within context. /// </summary> public void CallOnAllInSameContext(IContextHandler context, Action<Character> callback) { context.EnsureContext(); foreach (var chr in GetCharacters()) { if (chr.ContextHandler == context) { callback(chr); } } }
public static ProcessResult DefaultRequestProcessor(object contentValue, IEnumerable<KeyValuePair<string, string>> beetlePrms, ActionContext actionContext, IBeetleService service, IContextHandler contextHandler, IQueryHandler<IQueryable> queryableHandler, IContentHandler<IEnumerable> enumerableHandler) { var queryable = contentValue as IQueryable; if (queryable != null) return queryableHandler.HandleContent(queryable, beetlePrms, actionContext, service, contextHandler); if (!(contentValue is string)) { var enumerable = contentValue as IEnumerable; if (enumerable != null) return enumerableHandler.HandleContent(enumerable, beetlePrms, actionContext, service, contextHandler); } return new ProcessResult(actionContext) { Result = contentValue }; }
/// <summary> /// Initializes the message handler. /// </summary> /// <param name="messageHandler">The message handler.</param> /// <param name="contextHandler">The context handler.</param> protected abstract void InitializeMessageHandler(object messageHandler, IContextHandler contextHandler);
/// <summary> /// Initializes a new instance of the <see cref="PolicyDecisionPoint"/> class. /// </summary> /// <param name="contextHandler">The configured contexthandler.</param> /// <param name="prp">The Policy Retrieval Point.</param> public PolicyDecisionPoint(IContextHandler contextHandler, IPolicyRetrievalPoint prp) { this.contextHandler = contextHandler; this.prp = prp; }
public RunContext(IContextHandler contextHandler, HooksHandler hooksHandler) { this.contextHandler = contextHandler; this.hooksHandler = hooksHandler; this.hooksHandler.SubscribeToHubEvents(this); }
/// <summary> /// Initializes a new instance of the <see cref="DecisionController"/> class. /// </summary> /// <param name="contextHandler">The Context handler</param> /// <param name="policyRetrievalPoint">The policy Retrieval point</param> /// <param name="logger">the logger.</param> public DecisionController(IContextHandler contextHandler, IPolicyRetrievalPoint policyRetrievalPoint, ILogger <DecisionController> logger) { _contextHandler = contextHandler; _prp = policyRetrievalPoint; _logger = logger; }
public Server(IContextHandler contextHandler) { _contextHandler = contextHandler; }
public static void DestroyInstance() { Debug.Assert(_contextHandler != null, "ContextInstance is null"); _contextHandler.SaveContexts(); _contextHandler = null; }
/// <summary> /// Initializes a new instance of the <see cref="DecisionController"/> class. /// </summary> /// <param name="contextHandler">The Context handler</param> /// <param name="policyRetrievalPoint">The policy Retrieval point</param> public DecisionController(IContextHandler contextHandler, IPolicyRetrievalPoint policyRetrievalPoint) { _contextHandler = contextHandler; _prp = policyRetrievalPoint; }
public override void Process(CmdTrigger <RealmServerCmdArgs> trigger) { Character chr = trigger.Args.Target as Character; IUser banner = trigger.Args.User; if (chr != null && object.ReferenceEquals((object)chr, (object)banner)) { chr = chr.Target as Character; } if (chr == null || object.ReferenceEquals((object)chr, (object)banner)) { trigger.Reply("Invalid Target."); } else if (banner != null && chr.Role >= banner.Role) { trigger.Reply("Cannot ban Users of higher or equal Rank."); } else { TimeSpan?nullable1 = trigger.Text.NextTimeSpan(); DateTime?until; if (nullable1.HasValue) { DateTime now = DateTime.Now; TimeSpan?nullable2 = nullable1; until = nullable2.HasValue ? new DateTime?(now + nullable2.GetValueOrDefault()) : new DateTime?(); } else { until = new DateTime?(); } string timeStr = until.HasValue ? "until " + (object)until : "(indefinitely)"; trigger.Reply("Banning Account {0} ({1}) {2}...", (object)chr.Account.Name, (object)chr.Name, (object)timeStr); ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((IMessage) new Message((Action)(() => { IContextHandler contextHandler = chr.ContextHandler; RealmAccount account = chr.Account; if (account == null || contextHandler == null) { trigger.Reply("Character logged off."); } else if (account.SetAccountActive(false, until)) { contextHandler.AddMessage((Action)(() => { if (chr.IsInWorld) { chr.Kick((INamed)banner, "Banned " + timeStr, 5); } trigger.Reply("Done."); })); } else { trigger.Reply("Could not ban Account."); } }))); } }
/// <summary> /// Initializes the message handler. /// </summary> /// <param name="messageHandler">The message handler.</param> /// <param name="contextHandler"></param> protected override void InitializeMessageHandler(object messageHandler, IContextHandler contextHandler) { SetPropertyToHandler(messageHandler, "Controller", this); SetPropertyToHandler(messageHandler, "Processor", Processor); SetPropertyToHandler(messageHandler, "Context", contextHandler); }