Beispiel #1
0
 public void EndedPR(int no)
 {
     if (cc == null)
     {
         return;
     }
     if (cc.SendEndPR(no) == false)
     {
         cc = null;
     }
 }
Beispiel #2
0
 public void EndedCoarting(int no, int bwcnt, int awcnt)
 {
     if (cc == null)
     {
         return;
     }
     if (cc.SendEndCoating(no, bwcnt, awcnt) == false)
     {
         cc = null;
     }
 }
Beispiel #3
0
 public void SetDrop(int no, int drop)
 {
     if (cc == null)
     {
         return;
     }
     if (cc.SendSetDrop(no, drop) == false)
     {
         cc = null;
     }
     ;
 }
Beispiel #4
0
 /// <summary>
 /// Sends the command at the designated Control EndPoint.
 /// Receives a response from the device at the same EndPoint when possible.
 /// </summary>
 /// <param name="command">The command to send.</param>
 public void SendCommand(byte[] command)
 {
     try
     {
         ControlClient.Send(command, command.Length);
         IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);            // TODO: Maybe change to read to defined source
         byte[]     receivedBytes    = ControlClient.Receive(ref RemoteIpEndPoint); // Maybe add timeout here (await/async)
         IsDeviceResponseValid(receivedBytes);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #5
0
        public override void GetConfigurationForm(DataFormResultEventHandler Callback, object State)
        {
            XmppAccountNode XmppAccountNode = this.XmppAccountNode;
            ControlClient   ControlClient;

            if (XmppAccountNode != null && (ControlClient = XmppAccountNode.ControlClient) != null)
            {
                ControlClient.GetForm(this.RosterItem.LastPresenceFullJid, "en", Callback, State);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Beispiel #6
0
        /// <summary>
        /// 初始化Connection,专用于服务一个成功连接的TcpClient
        /// <para>Sets up the class to handle the communication to the given TcpClient.</para>
        /// </summary>
        /// <param name="client">The TcpClient to communicate with.</param>
        public async override void HandleClient(object obj)
        {
            TcpClient client = obj as TcpClient;

            ControlClient = client;

            RemoteEndPoint = (IPEndPoint)ControlClient.Client.RemoteEndPoint;

            ClientIP = RemoteEndPoint.Address.ToString();

            ControlStream = ControlClient.GetStream();

            OnConnected();
        }
Beispiel #7
0
        public override void DisposeClients()
        {
            if (this.controlServer != null)
            {
                this.controlServer.Dispose();
                this.controlServer = null;
            }

            if (this.controlClient != null)
            {
                this.controlClient.Dispose();
                this.controlClient = null;
            }

            base.DisposeClients();
        }
Beispiel #8
0
        public override void GetConfigurationForm(DataFormResultEventHandler Callback, object State)
        {
            XmppConcentrator Concentrator    = this.Concentrator;
            XmppAccountNode  XmppAccountNode = Concentrator.XmppAccountNode;
            ControlClient    ControlClient;

            if (XmppAccountNode != null && (ControlClient = XmppAccountNode.ControlClient) != null)
            {
                ControlClient.GetForm(Concentrator.RosterItem.LastPresenceFullJid, "en", Callback, State,
                                      new ThingReference(this.nodeInfo.NodeId, this.nodeInfo.SourceId, this.nodeInfo.Partition));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
        static void Main(string[] args)
        {
            List <string> urls       = new List <string>();
            List <string> recipients = new List <string>();
            List <string> tags       = new List <string>();

            urls.Add("https://www.ibm.com/developerworks/views/global/rss/libraryview.jsp");
            recipients.Add("*****@*****.**");
            tags.Add("development");
            ControlClient controlClient = new ControlClient();

            Console.ReadLine();

            SynItems items = controlClient.ProcessFeeds(urls.ToArray(), tags.ToArray(), recipients.ToArray());

            Console.ReadLine();
        }
Beispiel #10
0
        public bool Shutdown()
        {
            try
            {
                ControlClient.Close();
                DataTransmissionClient.Close();
                StorageDataReadingClient.Close();
                // TODO: Add task cancellation

                return(true);
            }
            catch (Exception)
            {
                return(false);
                //throw;
            }
        }
Beispiel #11
0
        private void Init(params ISniffer[] Sniffers)
        {
            if (!string.IsNullOrEmpty(this.passwordHash))
            {
                this.client = new XmppClient(this.host, this.port, this.account, this.passwordHash, this.passwordHashMethod, "en", typeof(App).Assembly);
            }
            else
            {
                this.client = new XmppClient(this.host, this.port, this.account, this.password, "en", typeof(App).Assembly);
            }

            if (Sniffers != null)
            {
                this.client.AddRange(Sniffers);
            }

            this.client.TrustServer            = this.trustCertificate;
            this.client.OnStateChanged        += new StateChangedEventHandler(Client_OnStateChanged);
            this.client.OnError               += new XmppExceptionEventHandler(Client_OnError);
            this.client.OnPresence            += new PresenceEventHandler(Client_OnPresence);
            this.client.OnPresenceSubscribe   += new PresenceEventHandler(Client_OnPresenceSubscribe);
            this.client.OnPresenceUnsubscribe += new PresenceEventHandler(Client_OnPresenceUnsubscribe);
            this.client.OnRosterItemAdded     += new RosterItemEventHandler(Client_OnRosterItemUpdated);
            this.client.OnRosterItemRemoved   += new RosterItemEventHandler(Client_OnRosterItemRemoved);
            this.client.OnRosterItemUpdated   += new RosterItemEventHandler(Client_OnRosterItemUpdated);
            this.connectionTimer               = new Timer(this.CheckConnection, null, 60000, 60000);
            this.client.OnNormalMessage       += Client_OnNormalMessage;

            if (this.allowInsecureAuthentication)
            {
                this.client.AllowPlain     = true;
                this.client.AllowCramMD5   = true;
                this.client.AllowDigestMD5 = true;
            }

            this.client.SetPresence(Availability.Chat);

            this.sensorClient       = new SensorClient(this.client);
            this.controlClient      = new ControlClient(this.client);
            this.concentratorClient = new ConcentratorClient(this.client);

            this.client.Connect();
        }
Beispiel #12
0
        public override void ConnectClients()
        {
            base.ConnectClients();

            Assert.AreEqual(XmppState.Connected, this.client1.State);
            Assert.AreEqual(XmppState.Connected, this.client2.State);

            this.controlClient = new ControlClient(this.client1);
            this.controlServer = new ControlServer(this.client2,
                                                   new BooleanControlParameter("Bool", "Page1", "Bool:", "Boolean value",
                                                                               (sender) => Task.FromResult <bool?>(this.b),
                                                                               (sender, value) => { this.b = value; return(Task.CompletedTask); }),
                                                   new ColorControlParameter("Color", "Page1", "Color:", "Color value",
                                                                             (sender) => Task.FromResult <ColorReference>(this.cl),
                                                                             (sender, value) => { this.cl = value; return(Task.CompletedTask); }),
                                                   new DateControlParameter("Date", "Page1", "Date:", "Date value", DateTime.MinValue, DateTime.MaxValue,
                                                                            (sender) => Task.FromResult <DateTime?>(this.d),
                                                                            (sender, value) => { this.d = value; return(Task.CompletedTask); }),
                                                   new DateTimeControlParameter("DateTime", "Page1", "DateTime:", "DateTime value", DateTime.MinValue, DateTime.MaxValue,
                                                                                (sender) => Task.FromResult <DateTime?>(this.dt),
                                                                                (sender, value) => { this.dt = value; return(Task.CompletedTask); }),
                                                   new DoubleControlParameter("Double", "Page1", "Double:", "Double value",
                                                                              (sender) => Task.FromResult <double?>(this.db),
                                                                              (sender, value) => { this.db = value; return(Task.CompletedTask); }),
                                                   new DurationControlParameter("Duration", "Page1", "Duration:", "Duration value",
                                                                                (sender) => Task.FromResult <Duration>(this.dr),
                                                                                (sender, value) => { this.dr = value; return(Task.CompletedTask); }),
                                                   new EnumControlParameter("Enum", "Page1", "Enum:", "Enum value", typeof(TypeCode),
                                                                            (sender) => Task.FromResult <Enum>(this.e),
                                                                            (sender, value) => { this.e = (TypeCode)value; return(Task.CompletedTask); }),
                                                   new Int32ControlParameter("Int32", "Page1", "Int32:", "Int32 value",
                                                                             (sender) => Task.FromResult <int?>(this.i),
                                                                             (sender, value) => { this.i = value; return(Task.CompletedTask); }),
                                                   new Int64ControlParameter("Int64", "Page1", "Int64:", "Int64 value",
                                                                             (sender) => Task.FromResult <long?>(this.l),
                                                                             (sender, value) => { this.l = value; return(Task.CompletedTask); }),
                                                   new StringControlParameter("String", "Page1", "String:", "String value",
                                                                              (sender) => Task.FromResult <string>(this.s),
                                                                              (sender, value) => { this.s = value; return(Task.CompletedTask); }),
                                                   new TimeControlParameter("Time", "Page1", "Time:", "Time value",
                                                                            (sender) => Task.FromResult <TimeSpan?>(this.t),
                                                                            (sender, value) => { this.t = value; return(Task.CompletedTask); }));
        }
Beispiel #13
0
 private void ReadFilterSendThreadMain()
 {
     if (ListBoxFeeds.Items.Count > 0)
     {
         tags.Clear();
         tags = TextBoxTags.Text.Split(' ').ToList();
         Links.Clear();
         ControlClient client = new ControlClient();
         SynItems      items  = client.ProcessFeeds(ListBoxFeeds.Items.Cast <string>().ToArray(), tags.ToArray(), ListBoxRecipients.Items.Cast <string>().ToArray());
         client.Close();
         ListBoxFeedItems.Invoke(new Action(() => ListBoxFeedItems.Items.Clear()));
         ListBoxFeedItems.Invoke(new Action(() => ListBoxFeedItems.Items.AddRange(items.Titles.ToArray())));
         Links.AddRange(items.Links);
         MainTimer.Stop();
         MainTimer.Interval = (double)(1000 * 60 * (NumericUpDownMinutes.Value + NumericUpDownHours.Value * 60 + NumericUpDownDays.Value * 60 * 24));
         MainTimer.Start();
         ActiveForm?.Invoke(new Action(() => ActiveForm.Text = "Mail sent at " + DateTime.Now));
     }
 }
        async Task RunControlAsync()
        {
            var cts = new CancellationTokenSource();

            try {
                var device = await ConnectAsync();

                using (var s = new LEStream(device)) {
                    client = new ControlClient(s);
                    variablesList.ItemsSource = client.Variables;
                    commandsList.ItemsSource  = client.Commands;
                    await client.RunAsync(cts.Token);
                }
            } catch (Exception ex) {
                Debug.WriteLine("Stream failed");
                Debug.WriteLine(ex);
            } finally {
                client = null;
            }
        }
Beispiel #15
0
        public override void ConnectClients()
        {
            base.ConnectClients();

            Assert.AreEqual(XmppState.Connected, this.client1.State);
            Assert.AreEqual(XmppState.Connected, this.client2.State);

            this.controlClient = new ControlClient(this.client1);
            this.controlServer = new ControlServer(this.client2,
                                                   new BooleanControlParameter("Bool", "Page1", "Bool:", "Boolean value", (sender) => this.b, (sender, value) => this.b = value),
                                                   new ColorControlParameter("Color", "Page1", "Color:", "Color value", (sender) => this.cl, (sender, value) => this.cl = value),
                                                   new DateControlParameter("Date", "Page1", "Date:", "Date value", DateTime.MinValue, DateTime.MaxValue, (sender) => this.d, (sender, value) => this.d = value),
                                                   new DateTimeControlParameter("DateTime", "Page1", "DateTime:", "DateTime value", DateTime.MinValue, DateTime.MaxValue, (sender) => this.dt, (sender, value) => this.dt = value),
                                                   new DoubleControlParameter("Double", "Page1", "Double:", "Double value", (sender) => this.db, (sender, value) => this.db         = value),
                                                   new DurationControlParameter("Duration", "Page1", "Duration:", "Duration value", (sender) => this.dr, (sender, value) => this.dr = value),
                                                   new EnumControlParameter("Enum", "Page1", "Enum:", "Enum value", typeof(TypeCode), (sender) => this.e, (sender, value) => this.e = (TypeCode)value),
                                                   new Int32ControlParameter("Int32", "Page1", "Int32:", "Int32 value", (sender) => this.i, (sender, value) => this.i     = value),
                                                   new Int64ControlParameter("Int64", "Page1", "Int64:", "Int64 value", (sender) => this.l, (sender, value) => this.l     = value),
                                                   new StringControlParameter("String", "Page1", "String:", "String value", (sender) => this.s, (sender, value) => this.s = value),
                                                   new TimeControlParameter("Time", "Page1", "Time:", "Time value", (sender) => this.t, (sender, value) => this.t         = value));
        }
Beispiel #16
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if (ControlClient != null)
                    {
                        ControlClient.Close();
                    }

                    if (ControlStream != null)
                    {
                        ControlStream.Close();
                    }
                }
            }

            _disposed = true;
            OnDisposed();
        }
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);
            man.StopDeviceMotionUpdates();

            InvokeOnMainThread(() =>
            {
                var speedVariable = client.Variables.FirstOrDefault(x => x.Name == "Speed");
                if (speedVariable != null)
                {
                    speedVariable.Value = 0;
                }

                var turnVariable = client.Variables.FirstOrDefault(x => x.Name == "Turn");
                if (turnVariable != null)
                {
                    turnVariable.Value = 0;
                }
            });

            client = null;
        }
Beispiel #18
0
 /// <summary>
 /// Populate values from the base palette.
 /// </summary>
 /// <param name="common">Reference to common settings.</param>
 public void PopulateFromBase(KryptonPaletteCommon common)
 {
     // Populate only the designated styles
     common.StateCommon.BackStyle   = PaletteBackStyle.ControlClient;
     common.StateCommon.BorderStyle = PaletteBorderStyle.ControlClient;
     ControlClient.PopulateFromBase();
     common.StateCommon.BackStyle   = PaletteBackStyle.ControlAlternate;
     common.StateCommon.BorderStyle = PaletteBorderStyle.ControlAlternate;
     ControlAlternate.PopulateFromBase();
     common.StateCommon.BackStyle   = PaletteBackStyle.ControlGroupBox;
     common.StateCommon.BorderStyle = PaletteBorderStyle.ControlGroupBox;
     ControlGroupBox.PopulateFromBase();
     common.StateCommon.BackStyle   = PaletteBackStyle.ControlToolTip;
     common.StateCommon.BorderStyle = PaletteBorderStyle.ControlToolTip;
     ControlToolTip.PopulateFromBase();
     common.StateCommon.BackStyle   = PaletteBackStyle.ControlRibbon;
     common.StateCommon.BorderStyle = PaletteBorderStyle.ControlRibbon;
     ControlRibbon.PopulateFromBase();
     common.StateCommon.BackStyle   = PaletteBackStyle.ControlRibbonAppMenu;
     common.StateCommon.BorderStyle = PaletteBorderStyle.ControlRibbonAppMenu;
     ControlRibbonAppMenu.PopulateFromBase();
 }
Beispiel #19
0
        protected internal ServiceController(Deserializer deserializer, Service service)
            : base(deserializer)
        {
            if (service == null)
            {
                throw new ArgumentNullException("service");
            }
            else if (service.ControlUrl == null)
            {
                throw new ArgumentException("The service has no ControlUrl.", "service");
            }
            else if (service.EventUrl == null)
            {
                throw new ArgumentException("The service has no EventUrl.", "service");
            }

            actions         = new CollectionMap <string, ServiceAction> ();
            state_variables = new CollectionMap <string, StateVariable> ();
            control_client  = new ControlClient(
                service.Type.ToString(), service.ControlUrl, deserializer.XmlDeserializer);
            event_client = new EventClient(state_variables, service.EventUrl);
        }
Beispiel #20
0
		/// <summary>
		/// Invoked when application execution is being suspended.  Application state is saved
		/// without knowing whether the application will be terminated or resumed with the contents
		/// of memory still intact.
		/// </summary>
		/// <param name="sender">The source of the suspend request.</param>
		/// <param name="e">Details about the suspend request.</param>
		private void OnSuspending(object sender, SuspendingEventArgs e)
		{
			var deferral = e.SuspendingOperation.GetDeferral();

			this.subscription?.Unsubscribe();
			this.subscription = null;

			this.registryClient?.Dispose();
			this.registryClient = null;

			this.chatServer?.Dispose();
			this.chatServer = null;

			this.bobClient?.Dispose();
			this.bobClient = null;

			this.sensorServer?.Dispose();
			this.sensorServer = null;

			this.sensorClient?.Dispose();
			this.sensorClient = null;

			this.controlClient?.Dispose();
			this.controlClient = null;

			this.xmppClient?.Dispose();
			this.xmppClient = null;

			this.secondTimer?.Dispose();
			this.secondTimer = null;

			db?.Stop()?.Wait();
			db?.Flush()?.Wait();

			Log.Terminate();

			deferral.Complete();
		}
Beispiel #21
0
        protected override void Initialize()
        {
            ScreenManager screenManager = new ScreenManager(this);
            this.Components.Add(screenManager);

            var backgroundscreen = new BackgroundScreen();
            screenManager.AddScreen(backgroundscreen);
            
            var debugScreen = new DebugScreen(screenManager, false);
            screenManager.Game.Components.Add(debugScreen);
            this.Services.AddService(typeof(IDebugScreen), debugScreen);

            var audioScreen = new Audio();
            screenManager.AddScreen(audioScreen);
            this.Services.AddService(typeof(IAudio), audioScreen);

            PopulationSimulator populationSimulator = new PopulationSimulator(0, 0);

            var swarmEmitterComponent = new SwarmEmitterComponent(populationSimulator);

            var swarmAnalysisComponent = new SwarmAnalysisComponent(this.Services.GetService(typeof(IDebugScreen)) as IDebugScreen);

            SwarmScreen1 swarmScreen = new SwarmScreen1(swarmEmitterComponent, swarmAnalysisComponent,  populationSimulator);
            screenManager.AddScreen(swarmScreen);

#if NETFX_CORE
            ControlClient controlClient = new ControlClient(swarmScreen, swarmAnalysisComponent);
#else
            ControlClient controlClient = new ControlClient(swarmScreen));
#endif     
            this.Services.AddService(typeof(IControlClient), controlClient);

            //SoundEngine.Init();
            
            base.Initialize();
        }
Beispiel #22
0
		private void AttachFeatures()
		{
			this.sensorServer = new SensorServer(this.xmppClient, true);
			this.sensorServer.OnExecuteReadoutRequest += (sender, e) =>
			{
				try
				{
					Log.Informational("Performing readout.", this.xmppClient.BareJID, e.Actor);

					List<Field> Fields = new List<Field>();
					DateTime Now = DateTime.Now;

					if (e.IsIncluded(FieldType.Identity))
					{
						Fields.Add(new StringField(ThingReference.Empty, Now, "Device ID", this.deviceId, FieldType.Identity, FieldQoS.AutomaticReadout));

						if (!string.IsNullOrEmpty(this.sensorJid))
						{
							Fields.Add(new StringField(ThingReference.Empty, Now, "Sensor, JID", this.sensorJid, FieldType.Identity, FieldQoS.AutomaticReadout));

							if (this.sensor != null)
							{
								if (!string.IsNullOrEmpty(this.sensor.NodeId))
									Fields.Add(new StringField(ThingReference.Empty, Now, "Sensor, Node ID", this.sensor.NodeId, FieldType.Identity, FieldQoS.AutomaticReadout));

								if (!string.IsNullOrEmpty(this.sensor.SourceId))
									Fields.Add(new StringField(ThingReference.Empty, Now, "Sensor, Source ID", this.sensor.SourceId, FieldType.Identity, FieldQoS.AutomaticReadout));

								if (!string.IsNullOrEmpty(this.sensor.Partition))
									Fields.Add(new StringField(ThingReference.Empty, Now, "Sensor, Partition", this.sensor.Partition, FieldType.Identity, FieldQoS.AutomaticReadout));
							}
						}

						if (!string.IsNullOrEmpty(this.actuatorJid))
						{
							Fields.Add(new StringField(ThingReference.Empty, Now, "Actuator, JID", this.actuatorJid, FieldType.Identity, FieldQoS.AutomaticReadout));

							if (this.actuator != null)
							{
								if (!string.IsNullOrEmpty(this.actuator.NodeId))
									Fields.Add(new StringField(ThingReference.Empty, Now, "Actuator, Node ID", this.actuator.NodeId, FieldType.Identity, FieldQoS.AutomaticReadout));

								if (!string.IsNullOrEmpty(this.actuator.SourceId))
									Fields.Add(new StringField(ThingReference.Empty, Now, "Actuator, Source ID", this.actuator.SourceId, FieldType.Identity, FieldQoS.AutomaticReadout));

								if (!string.IsNullOrEmpty(this.actuator.Partition))
									Fields.Add(new StringField(ThingReference.Empty, Now, "Actuator, Partition", this.actuator.Partition, FieldType.Identity, FieldQoS.AutomaticReadout));
							}
						}
					}

					if (e.IsIncluded(FieldType.Status))
					{
						RosterItem Item;

						if (string.IsNullOrEmpty(this.sensorJid))
							Fields.Add(new StringField(ThingReference.Empty, Now, "Sensor, Availability", "Not Found", FieldType.Status, FieldQoS.AutomaticReadout));
						else
						{
							Item = this.xmppClient[this.sensorJid];
							if (Item is null)
								Fields.Add(new StringField(ThingReference.Empty, Now, "Sensor, Availability", "Not Found", FieldType.Status, FieldQoS.AutomaticReadout));
							else if (!Item.HasLastPresence)
								Fields.Add(new StringField(ThingReference.Empty, Now, "Sensor, Availability", "Offline", FieldType.Status, FieldQoS.AutomaticReadout));
							else
								Fields.Add(new StringField(ThingReference.Empty, Now, "Sensor, Availability", Item.LastPresence.Availability.ToString(), FieldType.Status, FieldQoS.AutomaticReadout));
						}

						if (string.IsNullOrEmpty(this.actuatorJid))
							Fields.Add(new StringField(ThingReference.Empty, Now, "Actuator, Availability", "Not Found", FieldType.Status, FieldQoS.AutomaticReadout));
						else
						{
							Item = this.xmppClient[this.actuatorJid];
							if (Item is null)
								Fields.Add(new StringField(ThingReference.Empty, Now, "Actuator, Availability", "Not Found", FieldType.Status, FieldQoS.AutomaticReadout));
							else if (!Item.HasLastPresence)
								Fields.Add(new StringField(ThingReference.Empty, Now, "Actuator, Availability", "Offline", FieldType.Status, FieldQoS.AutomaticReadout));
							else
								Fields.Add(new StringField(ThingReference.Empty, Now, "Actuator, Availability", Item.LastPresence.Availability.ToString(), FieldType.Status, FieldQoS.AutomaticReadout));
						}
					}

					if (e.IsIncluded(FieldType.Momentary))
					{
						if (this.light.HasValue)
							Fields.Add(new QuantityField(ThingReference.Empty, Now, "Light", this.light.Value, 2, "%", FieldType.Momentary, FieldQoS.AutomaticReadout));

						if (this.motion.HasValue)
							Fields.Add(new BooleanField(ThingReference.Empty, Now, "Motion", this.motion.Value, FieldType.Momentary, FieldQoS.AutomaticReadout));

						if (this.output.HasValue)
							Fields.Add(new BooleanField(ThingReference.Empty, Now, "Output", this.output.Value, FieldType.Momentary, FieldQoS.AutomaticReadout));
					}

					e.ReportFields(true, Fields);
				}
				catch (Exception ex)
				{
					e.ReportErrors(true, new ThingError(ThingReference.Empty, ex.Message));
				}

				return Task.CompletedTask;
			};

			this.xmppClient.OnError += (Sender, ex) =>
			{
				Log.Error(ex);
				return Task.CompletedTask;
			};

			this.xmppClient.OnPasswordChanged += (Sender, e) =>
			{
				Log.Informational("Password changed.", this.xmppClient.BareJID);
			};

			this.xmppClient.OnPresenceSubscribe += (Sender, e) =>
			{
				Log.Informational("Accepting friendship request.", this.xmppClient.BareJID, e.From);
				e.Accept();
				return Task.CompletedTask;
			};

			this.xmppClient.OnPresenceUnsubscribe += (Sender, e) =>
			{
				Log.Informational("Friendship removed.", this.xmppClient.BareJID, e.From);
				e.Accept();
				return Task.CompletedTask;
			};

			this.xmppClient.OnPresenceSubscribed += (Sender, e) =>
			{
				Log.Informational("Friendship request accepted.", this.xmppClient.BareJID, e.From);

				if (string.Compare(e.FromBareJID, this.sensorJid, true) == 0)
					this.SubscribeToSensorData();

				return Task.CompletedTask;
			};

			this.xmppClient.OnPresenceUnsubscribed += (Sender, e) =>
			{
				Log.Informational("Friendship removal accepted.", this.xmppClient.BareJID, e.From);
				return Task.CompletedTask;
			};

			this.xmppClient.OnPresence += XmppClient_OnPresence;

			this.bobClient = new BobClient(this.xmppClient, Path.Combine(Path.GetTempPath(), "BitsOfBinary"));
			this.chatServer = new ChatServer(this.xmppClient, this.bobClient, this.sensorServer);

			// XEP-0054: vcard-temp: http://xmpp.org/extensions/xep-0054.html
			this.xmppClient.RegisterIqGetHandler("vCard", "vcard-temp", this.QueryVCardHandler, true);

			this.sensorClient = new SensorClient(this.xmppClient);
			this.controlClient = new ControlClient(this.xmppClient);
		}
Beispiel #23
0
        private async Task ShutdownClient(ControlClient client)
        {
            await Task.Yield();

            await client.Disconnect();
        }