How do I keep an Android P2P WEBRTC server from sleeping

  • Hi

    I'm trying to put a P2P app together on Android using WebRTC. However, if the person acting as the server minimizes the app or leaves their device unattended for a while the device will go to sleep and everything breaks down (lost connections to the server etc -- which is understandable)

    What is the best way, using C2, to have the acting server NOT sleep? I've seen things about the 'keep screen on' property and wake locks, however, how does one utilize those in C2? Ideally it would be something programmatic such that I would only ask the acting server to remain 'awake' while the other clients didn't have to....

    Maybe a more overarching question is, do WevRTC apps play well with Android sleep and power optimization features? :S

    And advice would be appreciated.

    Thanks.

    -Remy

  • Any takers? Will this model of P2P in WebRTC even be able to be supported with Android features like Doze coming in Marshmallow? {deep sleeping}

    OR, will people need to connect NodeJS or other server to communicate?

  • Since this is probably a pretty niche question, perhaps I should ask you Ashley?

  • This doesn't really seem to me to be a C2 related question.

    As you say, it seems a little 'niche' to me also, although there may be one or two interested in any response, if there is anyone who even can :/

    In the meantime, maybe a more appropriate place to ask such a question would be a proper Android dev forum?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • WebRTC hosts can keep themselves running on desktop OSs, but I think the Android OS puts the app to sleep when to focus away. I think that's entirely reasonable. It's a weird idea to run a persistent server on a battery-powered OS.

  • Thanks for the responses Ashley and zenox98... I didn't mean to imply that I'd want a mobile host to be a <b>persistent</b> server, but rather one <b>that persists shortly </b> (perhaps for a 10-15 minute game cycle? -- after that there wouldn't be any further server duty obligation)... It's not for even for a fast

    twitchy multi-player game, more like a glorified version of the WebRTC chat-demo that comes with C2... If the host minimizes and time passes -- they take the party with them.

    Perhaps the novelty of not requiring anything other than a signaling server was too good to be true in this mobile age we live in?

    -Remy

  • It'd still kill your battery. I think it's better to encourage people to use non-battery-powered systems to host.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)