Reputation: 4286
A new feature in Windows 10 Universal apps is that you can transfer ownership (SocketStream.TransferOwnership) of a StreamSocket to the "socket broker" when the app is not running, and then react to socket activity through a Socket Activity Trigger.
There's a sample here https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/SocketActivityStreamSocket
However I'm having a hard time figuring whether this could be used in the scenario of for instance an IRC client on Windows 10 mobile. It would seem the socket would have nearly constant activity and the trigger would only run occasionally? Ideally you'd want to use the "background socket" to log all socket activity when its not running in the foreground...
I haven't really been able to find much about this feature and the MSDN documentation is pretty sparse
Upvotes: 2
Views: 872
Reputation: 4680
It would seem the socket would have nearly constant activity and the trigger would only run occasionally? Ideally you'd want to use the "background socket" to log all socket activity when it is not running in the foreground
When the socket ownership was transferred to background, the background task will be triggered when there are any socket activates. For example, new data was sent from the socket server or the socket was closed.
If you only want to background task to handle log the socket activities when the app is not running in the foreground, the app can take the ownership back though the code as following:
SocketActivityInformation socketInformation;
if (SocketActivityInformation.AllSockets.TryGetValue(SOCKET_ID, out socketInformation))
{
socket = socketInformation.StreamSocket;
}
App start: take the ownership back
App suspending: transfer the ownership
App resume: take the ownership back
Please correct me if I have any misunderstandings on your question :)
Upvotes: 1