[Plugin] AirConsole - local multiplayer for your game

0 favourites
From the Asset Store
"Easy Local Notifications" enhances games with customizable local notifications.
  • arod17pr glad Psychokiller1888 was able to assist but as he suggested you need to learn some basic JS as it will help you greatly! you still have enough time. Goodluck!

  • ishmaelmoreno

    That will be my goal. Thanks for the advice.

    By the way, I just finished my controller. Thanks for the help.

  • AirConsole just merged my latest Pull request

    Version 1.4.9.2

    • New condition "IsPluginOffline"

    This condition will check if you are running your Construct 2 project while being offline.

    Please note that from now on, whenever you try to preview or run a Construct 2 game without any internet connection, your console will warn you that the plugin is offline and uses a mock up of AirConsole in order to avoid the fatal JS error "AirConsole is undefined"

    This is especially needed for gmae where you implement other control setup and intend to run your game offline

    Official git repo: https://github.com/AirConsole/airconsole-construct2

    My git repo: https://github.com/Psychokiller1888/air ... construct2

  • Psychokiller1888 thank you for the update arod17pr no problem!

  • Before I go further with debugging I thought it might be some known issue so I'll ask.

    When I test my game with two controllers, the first one always connects properly as it receives the handshake trigger from the screen. Second controller however has like 50/50 chances to connect or not. It is connected to the airconsole (icon visible in top right corner) but "On device join" condition is not being triggered and so the controller is not connected to the game.

    I've debugged the controller and it is sending the handshake to device 0. I use the standard part in my controler for that as below:

    var airConsole = new AirConsole({orientation: AirConsole.ORIENTATION_LANDSCAPE});
        // var rateLimiter = new RateLimiter(airConsole);
    
        var sendHandshake = function () {
            airConsole.message(AirConsole.SCREEN, {
                handshake: true
            });
        };
    
        airConsole.onReady = function () {
            sendHandshake();
        };
    
        /** -------- AIR CONSOLE MESSAGES --------- **/
        airConsole.onMessage = function (device_id, data)
        {
            if (data.handshake) {
                sendHandshake();
            }[/code:22c9mr75]
    
    I also put just few quick logs to the runtime.js of the plugin and "[i][u]this.air_console.onMessage = function(device_id, data)[/u][/i]" is not even triggered, therefore it can't process the handshake.
    
    So simply saying, if the screen broadcasts  "Game is ready" then controllers connect, but when the screen is already loaded and it's the controller who sends the handshake, then it's like 50/50 that the Plugin will catch it.
    
    I'm using AirConsole plugin v1.4.8.1
    
    Are you maybe familiar with this issue  @Psychokiller1888?
    
    Thanks
    
    ==EDIT==
    Updated to newest plugin version. Still same problem. Screen just logs in console that "WebRTC active for device_id 2", but the plugin is not triggering anything.
  • Are you having these issues while using the simulator or in production?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Are you having these issues while using the simulator or in production?

    Using a link via their site: http://www.airconsole.com/?http=1#http://my.server.com/

    EDIT: Just checked simulator and all works perfect there. That's interesting.

    EDIT2: Ah no it's not... after more tests it start to have the same issue in simulator.

  • Well, I cannot say much because I also do have these issues sometimes. What I can say for sure is that I never had them using an android device, but one of my team mate has an older iphone and an ipad that does that like.... all the time.... I don't know how you handle the JS on your controller, but seeing the identation it looks like that part of the code you shared is under something, I think you instanciate AirConsole under $(document).ready() ? I increased the perfs a lot doing it that way. Something you should try, to see if any difference is actually upload your game without putting it in review, so you can preview it. Usually a lot of things gets fixed doing so

  • Well, I cannot say much because I also do have these issues sometimes. What I can say for sure is that I never had them using an android device, but one of my team mate has an older iphone and an ipad that does that like.... all the time.... I don't know how you handle the JS on your controller, but seeing the identation it looks like that part of the code you shared is under something, I think you instanciate AirConsole under $(document).ready() ? I increased the perfs a lot doing it that way. Something you should try, to see if any difference is actually upload your game without putting it in review, so you can preview it. Usually a lot of things gets fixed doing so

    Ah, then it might be something in the AC API actually. I was suspecting that as well. My controller is quite big so I spread the code across several classes that's why the indentation.

    Alright. Thanks for getting back!

  • Thing is also, Unity devs report like.... No real problems, based on my meeting with Alice in Zurich, and I reported quite many....... Some problemsare also coming from C2 in my opinion. In an attempt to make things easier, I have starteed rebuilding the plugin into a new version, that gets rid of the handshake thingy. It's far from finish, it's only a draft and I didn't have the time lately to make it any further, but keep my repo somewhere in your favs and feel free to ask for specific features to make the plugin version 2 even better!

    https://github.com/Psychokiller1888/c2airconsole

  • Will do - thanks again

  • Okay, so I managed to make a quick&dirty "hotfix" for this issue. The point is that the handshake message is sometimes not fetch by C2 code for some reason. So I tried to reattempt the handshaking and it works with every second handshake attempt on my end.

    So basically something like that:

        var isWelcomedByTheScreen = false;
        var handShakeReattempt;
    
        var sendHandshake = function () {
            if( ! isWelcomedByTheScreen)
            {
                console.log('sending handshake');
                airConsole.message(AirConsole.SCREEN, {
                    handshake: true
                });
    
                handShakeReattempt = setTimeout(function(){ sendHandshake() }, 700);
            }
        };[/code:1o2tg1ho]
    
    Now when you finally receive confirmation from the Screen:
    [code:1o2tg1ho]
                        if( ! isWelcomedByTheScreen)
                        {
                            console.log('welcome received');
                            clearTimeout(handShakeReattempt);
                            isWelcomedByTheScreen = true;
                        }[/code:1o2tg1ho]
    
    I presume this issue affects all C2 AC apps, so here's the easy workaround for now.
  • Good job! I did something similar too but did not continue as I changed the way it works in my plugin. Will redirect people to your post if someone asks about the same issue!

  • lol i had the same problem and tryed something similar but simpler, i just keep sending messages and handling the "login" when receiving messages (because the problem is that the "ondevicejoin" is not triggered, but the device actually can send messages)

  • Hmmm. I couldn't get ondevicejoin working for awhile, but realized I hadn't set maxplayers correctly. Now I am getting duplicates of ondevicejoin approximately 1 time out of 6. In C2, I just kept track of all joined deviceids, and ignored the duplicate calls.

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