• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

HTML5 Can Multiplayer be done with the HTML5 Version of GMS 2

RifleFire

Member
YOYO Customer Service said Yes but upon going to the manual, it appears to say that networking is not supported yet. The networking page for GMS2 says something like "these functions not supported for the HTML5 Target Module" about 2/3 down the page. I was going to buy the HMTL5 (WEB) version of GMS 2 to do a multiplayer type chess game but now i am unsure what to do. Can anyone tell me if the HTML5 version of GMS2 will ever be able to support more than 1 player at a time? An if it can, how is multiplayer done in the HTML5 (WEB) version of GMS2?
Many Thanks for your help!
RF
 
Last edited:

True Valhalla

Full-Time Developer
GMC Elder
HTML5 multiplayer is possible in GMS2 by using extensions, however, it can be extremely complicated. The networking functionality you need is not built into GMS2.

My studio's major project Kingfall is a HTML5 multiplayer game that is being designed to support millions of players.
 

FrostyCat

Redemption Seeker
Let's not exaggerate the actual difficulty of networking in the HTML5 export. It's hard to master, but I've seen much harder things to learn.

Yes, it requires extension work to support Websockets, and like all kinds of networking it requires more and more complicated sleight-of-hands and mitigative measures at higher scales. But the basics of making a connection to a server and sending a message aren't that hard, and anyone smart enough to know that another language will be involved and learn it can do a basic server at the 20-40 player scale.

To demonstrate my point, here is the entirety of the JS additions from my old Websockets plugin:
Code:
var __ws_sockets__ = new Array();
function __ws_connect__(url) {
    return __ws_connect_ext__(url, "");
}

function __ws_connect_ext__(url, protocols) {
    var ws, id;
 
    //Try to create the WebSocket
    try {
        if (protocols == "") {
            ws = new WebSocket(url);
        }
        else {
            ws = new WebSocket(url, protocols.split('|'));
        }
    }
    catch (e) {
        return -1;
    }
 
    //Add the WebSocket
    id = __ws_sockets__.push({
        socket: ws,
        inbox: new Array()
    })-1;
 
    //Tack on events
    ws.onmessage = function(event) {
        __ws_sockets__[id].inbox.push(event.data);
    };
 
    //Return numeric handle
    return id;
}

function __ws_status__(id) {
    try {
        return __ws_sockets__[id].socket.readyState;
    }
    catch (e) {
        return -1;
    }
}

function __ws_disconnect__(id) {
    return __ws_disconnect_ext__(id, 1000, "");
}

function __ws_disconnect_ext__(id, code, reason) {
    try {
        __ws_sockets__[id].socket.close(code, reason);
    }
    catch (e) {
        return false;
    }
}

function __ws_send_message__(id, msg) {
    try {
        __ws_sockets__[id].socket.send(msg);
        return true;
    }
    catch (e) {
        return false;
    }
}

function __ws_has_message__(id) {
    try {
        return __ws_sockets__[id].inbox.length > 0;
    }
    catch (e) {
        return false;
    }
}

function __ws_get_message__(id) {
    try {
        return (__ws_sockets__[id].inbox.splice(0, 1))[0] || "";
    }
    catch (e) {
        return "";
    }
}
Come on now, I've seen more code in the Step event of a Spalding-style platformer than that.

On the HTML5 export, real-time two-way networking is done through Websockets, and slower request-response traffic through HTTP. I've experimented with both, and in terms of how hard it is to get started, it's on the easy side for anyone who understands the principles of correspondence chess. The challenge is establishing the protocol and API for a final product, not establishing the initial connection.

One thing that I wish rookies would stop hoping for is full TCP/UDP networking on HTML5. Anyone who pays attention to web standards would know it has been shot down in 2015 due to security concerns and low adoption among vendors. This means NO browser will ever support TCP/UDP networking without non-standard additions to the browser itself, until the W3C changes course.
 

RifleFire

Member
FrostyCat,
Please forgive the earlier rookie question. I was just evaluating the feasibility of buying the web html5 version based on the potential to do MP networked games in it. Looks like i may stick to the gms2 versions for windows and other targets till i am more knowledgeable. Thank you and True Valhalla for your comments. God bless you both.
RF
 
Last edited:
Top