Question

I'm using MQTT Server TCP Connection to develop my Chat Application with Image Attachments.

The Text Chat is working fine but when comes to image attachments,the connection is getting lost and going to Application_Deactivated event.

I've tried connecting it back in the Application_Activated and Application_Launching Event,but even that doesn't work.

Is there any solution to maintain a TCP connection throughout the application background without loosing the Connection?

Actually while googling the solution, I came across Background Agents,is that going to work for me?If so,Can I get a perfect link for the tutorial?

Was it helpful?

Solution

The short answer is that you're not going to be able to maintain the TCP session when the user does something to leave your application (whether user backs out of the app or launches some other app). You should look into an API that the server supports to resume an existing user chat session over a new TCP session. I don't know MQTT to provide more specifics on how to achieve this magic. But once you figure it out, you'll want to use that mechanism to try to resume an existing chat session in both your Application_Launching and Application_Activated events.

A BackgroundAgent cannot run more often than every 30 minutes (except when debugging), that isn't frequent enough to keep a TCP session alive.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top