WebRTC on iOS - multiplayer is possible

0 favourites
  • 11 posts
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • I was told there are more WebRTC apps running on iOS than there are running on Android? And I was wondering if anyone has info about when it may be available for the Chrome or Safari web browser?

    Is there a way to make a Construct 2 game that has multiplayer ( using WebRTC ) - that would work on the iOS? Or is it very complicated?

    I believe iOS ( an iPhone ) uses apps.. or wants to use apps, instead of using a web browser as a middle ware. And there's lots of self-sustaining apps out there using WebRTC? But there's not support in Chrome or Safari for WebRTC? This is perhaps because browser support isn't irrelevant for many vendors creating apps.

    *btw I'm an iPhone newbie, just got my first one.

  • It's going to be more complicated to get the MP plugin working on IOS than Android.

    There is a Cordova/PhoneGap plugin for WebRTC that should be just WebRTC. You will need that plugin for either CocoonJS or PhoneGap. This is not a C2 plugin, so you will be working out side of the C2 environment. Also I'm not sure if any extra tinkering if any is going to be needed.

    So the plugin may work out of the box, or the plugin may no. If it does great, it works, not to much of a problem. If the plugin doesn't some one will need to find out what's not working and fix it.

  • I'm just with the same problem on iOS. Multiplayer games I'm working on runs smoothly on Android but on iOS is another history.

    I'm only been able to make it working on iOS using Bowser, exporting the games to HTML5. Bowser is the only browser on iOS that, to date, supports WebRTC. But Bowser has his pitfalls, is not as competent as Safary or Chrome in terms of funcionallity. But to make Construct 2 multiplayer-games work on iOS is near perfect.

    I'm trying to use CocoonJS also. But all my tests have failed and I think that CocoonJS doesn't support WebRTC at all, or his support is not as complete as to make multiplayer-games made with Construct 2 works.

    A question: could it be possible to modify the Construct 2 Multiplayer plugin to use that Cordova/PhoneGap plugin for WebRTC jayderyu just mentioned?

  • CocoonJS does not support many features that the entire C2 relies on. CJS does support a lot of the core game elements. Unfortunatly WebRTC and advanced WebAudio are not in that list. Though CJS does support audio their own audio system to at least have good sound to an extent.

    The best way to get WebRTC is to find the closest to the WebRTC api standard. there are a few, but I think this one might be the closest.

    https://github.com/eface2face/cordova-plugin-iosrtc

    Create a plugin that shims( https://en.wikipedia.org/wiki/Shim_(computing) ) C2 use of the webrtc of a browser, to the cordova plugin. The shim puts all the missing functions and references and makes links to the cordova plugin. If the plugin and shim supports all the same functions as what C2 uses. Then you should have WebRTC on IOS.

    It's not impossible. It's not even extremely hard. Shims are easy to create. But it is a level of technical knowledge required to use Cordova, some swift, C2 Plugin SDK, and javascript. So it's not a drop and use feature with IOS right now. <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

  • jayderyu I've been looking to that Cordova plugin (iosrtc). And I've an idea but don't know if it's doable. My technicall knwoledge about Cordova and iOS is not very advanced.

    My idea is to "duplicate" the "Multiplayer" plugin of C2 and call it, for example, "Multiplayer2". Then modify "Multiplayer2" to detect if is executing under iOS (think this is trivial) and if in iOS "shim" (or whatever you call it) the RTCPeerConnection functionallity that, if I'm not wrong, is the only function that Multiplayer uses.

    From c2mp-peer.js of C2 Multiplayer:

    var RTCPeerConnection = window["RTCPeerConnection"] || window["webkitRTCPeerConnection"] || window["mozRTCPeerConnection"] || window["msRTCPeerConnection"];[/code:gfbk8165]
    
    I'm planning to add something like this:
    
    [code:gfbk8165]// Just for Cordova apps.
    document.addEventListener('deviceready', function () {
      // Just for iOS devices.
      if (window.device.platform === 'iOS') {
        cordova.plugins.iosrtc.registerGlobals();
      }
    });[/code:gfbk8165]
    
    As they say in his documentation:
    
    [quote:gfbk8165] iosrtc.registerGlobals()  also [b]generates  window.webkitRTCPeerConnection  and  navigator.webkitGetUserMedia()  for backwards compatibility with WebRTC JavaScript wrappers/adapters[/b] that assume browser vendor prefixes ( webkit ,  moz ) in the underlying WebRTC API.
    
    
    In theory if I generate for Cordova in C2 and add the Cordova plugin:
    
    [code:gfbk8165]$ cordova plugin add cordova-plugin-iosrtc[/code:gfbk8165]
    
    Then this should work on iOS.
    
    As I said although I'm veteran programmer I'm not familizarized enough with Cordova internals and C2 plugins. And never have done anything for iOS nativelly, only small hybrid apps with Cordova.
    
    But, do you think this could work?
  • I say go for it. I was checking out the source code for iosrtc, and comparing c2mp-peer.js use of WebRTC function calls, and it does look like a number of them already exist. I didn't find any missing functions, but I didn't go over everything with a fine tooth comb either. I say give it a try and find a way to constantly check for errors. Send out a lot of console logs and watch xcode's debugging. See if and where it fails. But I think iosrtc looks viable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll give it a try. But this will be when I return from my Holidays!!!.

  • Hi DID you get this working ?

    Would love to get multiplay on ios too work

    REGARDS

  • flemmig any luck with your multiplay on IOS?

  • Yes - BUT did it with other solution

    Used the Photon - plugin and this is running fine in both iOS and Android

  • flemmig Thanks, i just installed that plugin and its flawless.

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