Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MessageHandler.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
6
8{
13 {
20 : base(Parent, Model)
21 {
22 }
23
27 public override string LocalName => nameof(MessageHandler);
28
36 {
37 return new MessageHandler(Parent, Model);
38 }
39
45 public override void RegisterHandlers(IActor Actor, XmppClient Client)
46 {
47 Client.RegisterMessageHandler(this.Name, this.HandlerNamespace, (sender, e) =>
48 {
49 this.Trigger(Actor, new KeyValuePair<string, object>(string.IsNullOrEmpty(this.EventArgs) ? "e" : this.EventArgs, e));
50 return Task.CompletedTask;
51 }, true);
52 }
53
54 }
55}
Root node of a simulation model
Definition: Model.cs:49
Abstract base class for actors
Definition: Actor.cs:15
ISimulationNode Parent
Parent node in the simulation model.
Abstract base class for handler nodes
Definition: HandlerNode.cs:19
string EventArgs
Variable name for the event arguments
Definition: HandlerNode.cs:76
string HandlerNamespace
Namespace for the handler
Definition: HandlerNode.cs:51
virtual void Trigger(IActor Source, params KeyValuePair< string, object >[] Arguments)
Method called when an external event has been received.
Definition: HandlerNode.cs:136
string Name
Local element name for the handler
Definition: HandlerNode.cs:46
override string LocalName
Local name of XML element defining contents of class.
MessageHandler(ISimulationNode Parent, Model Model)
Custom message handler.
override void RegisterHandlers(IActor Actor, XmppClient Client)
Registers handlers on the XMPP Client.
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
void RegisterMessageHandler(string LocalName, string Namespace, EventHandlerAsync< MessageEventArgs > Handler, bool PublishNamespaceAsClientFeature)
Registers a Message handler.
Definition: XmppClient.cs:2828
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Definition: IActor.cs:11