Jonna
Jonna

Reputation: 1645

WinRT - is it possible to create a service?

I want to create an WinRT app that would handle requests coming from phone in local/wifi network. Say for example, I already have a mouse app in phone (similar to this). I want to write the server app that would be on the PC/tablet that handles the requests from the mouse app in phone. So whenever I open the mouse app in phone, I can send a push notification which should enable the server (win 8 app) to handle all the subsequent requests coming from the phone app. Is it doable?

Normally, I would create a windows service for this but wanted to check if it is possible in WinRT.

Upvotes: 2

Views: 749

Answers (3)

Denis
Denis

Reputation: 4115

I'd say your best bet is ControlChannelTrigger. I haven't used it myself but based on its description it is designed to enable your scenario.

Enables real time notifications to be received in the background for class elements in the Windows.Networking.Sockets namespace and other networking transports.

Upvotes: 4

Prof. Falken
Prof. Falken

Reputation: 24867

Yes, you can use the StreamSocketListener class, but as jwillmer said, probably only as long as your application is running in the foreground.

Upvotes: 0

jwillmer
jwillmer

Reputation: 3790

I haven’t tested it myself but I would say it is possible. But only as long as your app is running in the foreground. If you switch to another app your app can't communicate anymore because the app is suspended.

Although you could have a look at "The Time" in the windows app store. It's a clock that refreshes the app tile every second (and the author blogged about it).

To connect to your app I would test signalR, heard good things about it :-)

Upvotes: 0

Related Questions