Multiplayer not working in NWjs as of r253

  • Problem Description

    When playing a game via NWjs, the multiplayer plugin reports that it is unavailable on this platform.

    This was likely caused by updated r253: https://www.scirra.com/construct2/releases/r253 as r253 changed/added to

    how the Multiplayer plugin checked for availability.

    The code below from c2mp.js of the Multiplayer plugin will always be undefined in NWjs, which leads the Multiplayer plugin to never be able to connect.

    var RTCDataChannel = window["RTCDataChannel"] || window["DataChannel"] || window["webkitRTCDataChannel"] || window["mozRTCDataChannel"] || window["msRTCDataChannel"];[/code:3ghc4of9]
    
    [b]Attach a Capx[/b]
    [url=https://drive.google.com/open?id=1Jh2jYr4_0f6fWHHAHz7FYmJZVaOJGTeH]https://drive.google.com/open?id=1Jh2jY ... JZVaOJGTeH[/url]
        
    [b]Description of Capx[/b]
    Basic Multiplayer chat sample Capx + Opens dev tools on startup.
    
    [b]Steps to Reproduce Bug[/b]
    [ul]
        [li] Export the Capx to NWjs
        [/li][li] Run the exported game on any platform (win, mac, linux)[/li][/ul]
        
    [b]Observed Result[/b]
    A large "Multiplayer is not available" message is present & no connections are possible
    Additionally, if you paste the code I mentioned above into the dev tools that appear, note that it returns `undefined`
        
    [b]Expected Result[/b]
    Multiplayer should work as expected in releases pre r253
        
    [b]Affected Browsers[/b]
    [ul]
        [li] NWjs: All platforms (win, mac, linux)
        [/li][li] Chrome: (NO)
        [/li][li] FireFox: (NO)
        [/li][li] Internet Explorer: (NO)[/li][/ul]
        
    [b]Operating System and Service Pack[/b]
    Win7 SP1
        
    [b]Construct 2 Version ID[/b]
    r255 64-bit
    
    [b]NWjs Version[/b]
    NWjs 0.19.4
    
    [b]Work Around[/b]
    Having this issue and need to release something with NWjs? Just follow these steps in the meantime <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">
    [ul]
    	[li]Open Construct 2/exporters/html5/plugins/multiplayer/c2mp.js[/li]
    [/ul][code:3ghc4of9]
    // Change this line
    return !!RTCPeerConnection && !!RTCDataChannel && typeof ArrayBuffer !== "undefined" && typeof DataView !== "undefined";
    		
    // To this
    return !!RTCPeerConnection && typeof ArrayBuffer !== "undefined" && typeof DataView !== "undefined";
    
    // Done!
    [/code:3ghc4of9]
  • I can't reproduce in NW.js 0.29.0. I think the problem is you're just using an old version of NW.js. We had to add that line to improve detection on the current versions of Firefox and Edge. It ought to work on older versions of NW.js too, I'm not sure why it wouldn't - it's long supported WebRTC Datachannels which is what the check is looking for...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yea thats weird... Either way, seems you are right and this issue is mainly because im on an older version of NWjs. Im gonna stick with this version for my project, but good to know going forward it should be all good to go.

    Thanks for taking a look

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