I'm looking into DNS based service discovery in Windows 10 and found this video from Build. The only change I made to discovery was changing the service name to "_ipp._tcp". However I don't get any hits even though I know I have > 15 IPP enabled printers on the network (I can successfully identify these using the ipptool, IOS and Android code).
I've checked and double checked for typos. I've included all networking capabilities in the appxmanifest file.
Here's my code, pretty straight forward:
public sealed partial class MainPage : Page
{
static Guid DnsSdProtocol = new Guid("{4526e8c1-8aac-4153-9b16-55e86ada0e54}");
string queryString = "System.Devices.AepService.ProtocolId:={" + DnsSdProtocol + "} AND " +
"System.Devices.Dnssd.Domain:=\"local\" AND System.Devices.Dnssd.ServiceName:=\"_ipp._tcp\"";
DeviceWatcher watcher;
public MainPage()
{
this.InitializeComponent();
}
private void button_Click(object sender, RoutedEventArgs e)
{
watcher = DeviceInformation.CreateWatcher(queryString,
new String[]
{
"System.Devices.Dnssd.HostName",
"System.Devices.Dnssd.ServiceName",
"System.Devices.Dnssd.TextAttributes",
"System.Devices.IpAddress" },
DeviceInformationKind.AssociationEndpointService
);
watcher.Added += Watcher_Added;
watcher.Start();
}
private void Watcher_Added(DeviceWatcher sender, DeviceInformation args)
{
System.Diagnostics.Debug.WriteLine("found device");
}
}
Does anybody else have experience with this and can help figure out why no devices are found? Is my query correct? Do I need to do anything else when setting up the DeviceWatcher?
update
I've verified the requests are being created since they are showing up in Wireshark. They look to be identical to other mdns requests being created. I've also verified I can create SSDP requests that return discovered devices so I doubt it's an issue with networking permissions via app capabilities.
Try using the watcher.Updated handler. Even if it is empty, the presence of an Updated handler can cause the Added handler to be triggered.
Related
i recently posted about connection to bluetooth devices using Xamarin. I managed to get the device and the mac address on a list. Im having a problem connecting to the device. It doesnt do anything when clicked... What are the next steps to pairing with device and is it even possible to pair with a fit watch, im trying to use the heart rate monitor on the fit watch as well.
I'm guessing the next step would be to setup a Click event on the list...
Something like
myListView = FindViewById<ListView>(Resource.Id.list);
myListView.ItemClick += List_Click;
private void List_Click(object sender, AdapterView.ItemClickEventArgs e)
{
//throw new NotImplementedException();
}
and is it possible to get the data from the fit watch and sync it with a chart.
I have managed to get a pie chart . now i just need to pair the fit watch and get the data from bluetooth. Any advice would be grateful thanks
You could get a BluetoothDevice object from the BluetoothAdapter
and something like :
myListView.ItemClick += List_Click;
private void List_Click(object sender, AdapterView.ItemClickEventArgs e)
{
var address = xxxxx; //the address you select
BluetoothDevice btDevice = mBluetoothAdapter.GetRemoteDevice(address);
var _socket = btDevice .CreateRfcommSocketToServiceRecord(UUID.FromString("00001101-0000-1000-8000-00805f9b34fb"));
_socket.Connect();
}
Much of the specifics for handling paired devices is in the documentation
I'm currently using the 32feet library for bluetooth in my application. I'm trying to check whether the device is still alive before it takes windows the 20s to change the status from "Connected" --> "Paired".
"True" --> "False"
I'm forcing a device refresh with:
holders.storedDevice.Refresh();
but it seems that the refresh isn't actually forcing windows to do anything. For reference storedDevice is of type
BluetoothDeviceInfo name {get; set;}
Timer code:
private void refreshDevice(object Sender, EventArgs e)
{
holders.StoredDevice.Refresh();
if(!holders.StoredDevice.Connected)
{
deviceRefreshTimer.Enabled = false;
updateTextBox( connectButton ,"Disconnecting...");
ExecuteSecure(() => connectButton.Enabled = false);
updateTextBox(statusTextBox, "Lost connection");
readBackgroundWorker.CancelAsync();
holders.localClient.Close();
storedStream = null;
}
}
I am trying to Network a small 2 player Unity game. This is my first go at networking, so please feel free to correct me on anything I am doing wrong. I am attempting to make a simple matchmaking service where, on the main menu of the game, a player can click the Find Match button. This will execute the following function
private HostData[] hostList;
private const string typeName = "UniqueGameName";
private const string gameName = "RoomName";
public void FindMatch() {
RefreshHostList();
if (hostList != null) {
JoinServer(hostList[0]);
} else {
StartServer();
}
}
And here are the corresponding methods called in that function.
private void RefreshHostList()
{
MasterServer.RequestHostList(typeName);
}
void OnMasterServerEvent(MasterServerEvent msEvent)
{
if (msEvent == MasterServerEvent.HostListReceived)
hostList = MasterServer.PollHostList();
}
private void JoinServer(HostData hostData)
{
Network.Connect(hostData);
}
private void StartServer()
{
Network.InitializeServer(2, 25000, !Network.HavePublicAddress());
MasterServer.RegisterHost(typeName, gameName);
}
The idea is, when the player clicks Find Match, it will refresh the host list. If it finds a host, it will join their server and begin a match. If it doesn't, it will begin its own server and wait for another player. When testing this, the first player that clicks Find Match is able to start a server, but then the second player receives the error message "...Is the listen port already in use?". When I debug and step through my program, the second player's hostList is always null, even with the first players successful server creation and registration.
Are you using both instances of app on same machine? If you occupy network port once then you are not able to initialize server on same port on the same machine.
In general I would recommend looking into SingalR technology for your needs, it uses websockets.
I made a program that handles NFC tags back in 2013, today after two years of pause on that program i continued with it, and ran into some strange problem. In the program i read NFC tags which are writen with a "window.Someid" so they are app specific.
For some reason, the program works perfectly when scanning the NFC tag, except, when i want to scan the tag for the second time, the handler doesn't fire. any idea what causes this? (i see no error message).
Here's my code:
ProximityDevice PDevice;
private long SubscriptionID = -1;
// Constructor
public MainPage()
{
InitializeComponent();
PDevice = ProximityDevice.GetDefault();
// subscribe for messages
SubscriptionID = PDevice.SubscribeForMessage("Windows.SomeMsg", ProximityMessageRcvd);
}
private void ProximityMessageRcvd(ProximityDevice sender, ProximityMessage message)
{
Debug.WriteLine("Message");
}
I seen one method of web service that is to call from a MCWebServiceSoapClient.
//getting the different points for the map when checkbox is checked
private void polyc_Checked(object sender, RoutedEventArgs e)
{
testingwcf.MCWebServiceSoapClient ob = new TestMap.testingwcf.MCWebServiceSoapClient();
ob.getPolytechnicPointsAsync();
ob.getPolytechnicPointsCompleted += new EventHandler<testingwcf.getPolytechnicPointsCompletedEventArgs>(ob_getPolyPointsCompleted);
}
However what I am implementing to call is WCF. How to do convert this method to a WCF ? My WCF is here http://kailun92wcf.cloudapp.net/Service1.svc. Is it possible to call from a WCF into windows phone ersi map ? To plot the points ?
You want to consume a WCF service from a WP app?
Firstly, generate your client proxy via visual studio, right click on "references", select "Add service reference", select the "Go" button, this wizard should discover your service if it is online.
Select the advanced button, and select the options below
in your code behind, hook up to a click event,
private void LoadWebService(object sender, RoutedEventArgs e)
{
var service = new Service1Client();
service.getRecommendPlaceAsync(new getRecommendPlaceRequest { activityId = 1}); //Provide your id here
service.getRecommendPlaceCompleted += new EventHandler<MyCloundService.getRecommendPlaceCompletedEventArgs>(RecommendedPlaceRequestComplete);
}
void RecommendedPlaceRequestComplete(object sender, MyCloundService.getRecommendPlaceCompletedEventArgs e)
{
if (e.Error == null)
{
var result = String.Join(",", (from place in e.Result.getRecommendPlaceResult select place.Name).ToArray());
MessageBox.Show(result);
}
else
{
MessageBox.Show("An error occured: " + e.Error.Message);
}
}
See a tutorial here
Seems like what you are trying to do is call a function on the phone from the WCF service you cant use event handlers over the wire like that especially not on a phone.
Because the phones run on battery you may want to use something like push notifications as detailed below:
Sending push notifications for Windows Phone
Setting up your app to receive push notifications for Windows Phone