コード例 #1
0
        private static void Register()
        {
            string Key = Guid.NewGuid().ToString().Replace("-", string.Empty);

            // For info on tag names, see: http://xmpp.org/extensions/xep-0347.html#tags
            MetaDataTag[] MetaData = new MetaDataTag[]
            {
                new MetaDataStringTag("KEY", Key),
                new MetaDataStringTag("CLASS", "PC"),
                new MetaDataStringTag("MAN", "waher.se"),
                new MetaDataStringTag("MODEL", "Waher.Service.PcSensor"),
                new MetaDataStringTag("PURL", "https://github.com/PeterWaher/IoTGateway/tree/master/Services/Waher.Service.PcSensor"),
                new MetaDataNumericTag("V", 1.0)
            };

            thingRegistryClient.RegisterThing(MetaData, (sender2, e2) =>
            {
                if (e2.Ok)
                {
                    registered = true;

                    if (e2.IsClaimed)
                    {
                        ownerJid = e2.OwnerJid;
                    }
                    else
                    {
                        ownerJid = string.Empty;
                        SimpleXmppConfiguration.PrintQRCode(thingRegistryClient.EncodeAsIoTDiscoURI(MetaData));
                    }
                }

                return(Task.CompletedTask);
            }, null);
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: xiaguoli/IoTGateway
		private void Register()
		{
			key = Guid.NewGuid().ToString().Replace("-", string.Empty);
			
			// For info on tag names, see: http://xmpp.org/extensions/xep-0347.html#tags
			metaData = new MetaDataTag[]
			{
				new MetaDataStringTag("KEY", key),
				new MetaDataStringTag("CLASS", "PLC"),
				new MetaDataStringTag("MAN", "waher.se"),
				new MetaDataStringTag("MODEL", "Waher.Service.GPIO"),
				new MetaDataStringTag("PURL", "https://github.com/PeterWaher/IoTGateway/tree/master/Services/Waher.Service.GPIO"),
				new MetaDataNumericTag("V",1.0)
			};

			qrCodeUrl = SimpleXmppConfiguration.GetQRCodeURL(ThingRegistryClient.EncodeAsIoTDiscoURI(metaData), 400, 400);

			thingRegistryClient.RegisterThing(metaData, (sender2, e2) =>
			{
				if (e2.Ok)
				{
					this.registered = true;

					if (e2.IsClaimed)
						ownerJid = e2.OwnerJid;
					else
						ownerJid = string.Empty;

					this.RaiseOwnershipChanged();
				}
			}, null);
		}