Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AvatarExtension.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(AvatarExtension);
28
36 {
37 return new AvatarExtension(Parent, Model);
38 }
39
46 public override Task<object> Add(IActor Instance, Waher.Networking.XMPP.XmppClient Client)
47 {
48 AvatarClient Extension = new AvatarClient(Client);
49 Client.SetTag("Avatar", Extension);
50
51 Extension.AvatarAdded += (Sender, e) =>
52 {
53 this.Model.ExternalEvent(Instance, "AvatarAdded",
54 new KeyValuePair<string, object>("e", e),
55 new KeyValuePair<string, object>("Client", Client));
56
57 return Task.CompletedTask;
58 };
59
60 Extension.AvatarRemoved += (Sender, e) =>
61 {
62 this.Model.ExternalEvent(Instance, "AvatarRemoved",
63 new KeyValuePair<string, object>("e", e),
64 new KeyValuePair<string, object>("Client", Client));
65
66 return Task.CompletedTask;
67 };
68
69 Extension.AvatarUpdated += (Sender, e) =>
70 {
71 this.Model.ExternalEvent(Instance, "AvatarUpdated",
72 new KeyValuePair<string, object>("e", e),
73 new KeyValuePair<string, object>("Client", Client));
74
75 return Task.CompletedTask;
76 };
77
78 Extension.VCardReceived += (Sender, e) =>
79 {
80 this.Model.ExternalEvent(Instance, "VCardReceived",
81 new KeyValuePair<string, object>("e", e),
82 new KeyValuePair<string, object>("Client", Client));
83
84 return Task.CompletedTask;
85 };
86
87 return Task.FromResult<object>(Extension);
88 }
89
90 }
91}
Root node of a simulation model
Definition: Model.cs:49
bool ExternalEvent(IExternalEventsNode Source, string Name, params KeyValuePair< string, object >[] Arguments)
Method called when an external event has been received.
Definition: Model.cs:889
override string LocalName
Local name of XML element defining contents of class.
override Task< object > Add(IActor Instance, Waher.Networking.XMPP.XmppClient Client)
Adds the extension to the client.
AvatarExtension(ISimulationNode Parent, Model Model)
Avatar XMPP extension
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
Abstract base class for XMPP extensions.
Provides help with managing avatars.
Definition: AvatarClient.cs:25
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Definition: IActor.cs:11
Definition: App.xaml.cs:4