websocket server inside c2 (stable multiplayer idea) !

Discussion and feedback on Construct 2

Post » Sun Aug 02, 2015 5:40 pm

hi since multiplayer is not stable (users mostly disconnected) its might be good for small games but no good for big games.
i have an idea which we can make a multiplayer with websocket and don't need to js programming !!! :shock:
this is what we need :
1 - nodejs server script
2 - server side game
3 - client side game
so we need to make a node js to pass the all client messages to the host and pass host messages to a specific client !
like this :
all clients >> node js server >> server game (we can run node js and server game in single host so the latency is 0)
game server >> node js server (get client username from the server message and send message to that user) >> a specific client
client message type is : (c$tag$username$data)
server message type is : (s$tag$username$data)
i will say why we have this type of messages !
so we need a node server to do that and i wanted to use ws module for nodejs but it doesn't respond sometimes !!
this is my code for ws server :
in my code server split messages and if "c" so this message from client and if "s" then its a server
"tag" is like tag in multiplayer plugin
"username" is client username (even in server messages)
so in server game and client game we can split messages with tokenat and then use them !
so anyone can help ?
Code: Select all

var WebSocketServer = require('ws').Server, wss = new WebSocketServer({port: 1337});
var connections = {};
wss.on('connection', function(ws) {
    ws.on('message', function(message,ws) {
        console.log('received: %s', message);
       
        var res = message.split("$");
        if(res[0] == "s")
        {
            ws.send(message);
           
                if(res[1] == "login")
                {
                    connections["server"] = ws;
                }
                else
                {
                    ws.send(message);
                    if(connections["client"])
                    {
                        connections[res[2]].send(res[1] + res[3]);
                    }
                }
               
        }
        else
        {
                if(res[1] == "login")
                {
                    connections[res[2]] = ws;
                }
                else
                {
                    connections["server"].send(res[1] + res[2] + res[3]);
                }
        }

    });
   
});
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Mon Aug 03, 2015 11:28 am

As far as I am aware Multiplayer is stable - people getting disconnected is probably due to network connectivity issues over the Internet itself, which would affect any technology you use to connect.

WebSocket is also limited to TCP transport which can make it perform poorly over unreliable connections.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842

Post » Mon Aug 03, 2015 12:24 pm

Ashley wrote:As far as I am aware Multiplayer is stable - people getting disconnected is probably due to network connectivity issues over the Internet itself, which would affect any technology you use to connect.

WebSocket is also limited to TCP transport which can make it perform poorly over unreliable connections.

in this line you just said multiplayer is not stable ! yes internet have problem and users get disconnected but this problem is for a few second and in multiplayer plugin you must try to reconnect them to each other fast and if this few second get bigger then you must disconnect them !
but in multiplayer plugin when they disconnect for just a second plugin disconnect them and doesn't try to reconnect them fast and we can not reconnect them fast because we must connect to your server and then login and then join room and then connect to game and this process take so much time for us .
but in websocket we can connect them fast again !
and due to this bug :
scirra.com/forum/viewtopic.php?f=146&t=150590
if host get disconnected from signalling server it does not know that sometimes !!!
B
16
S
6
Posts: 243
Reputation: 1,755


Return to Construct 2 General

Who is online

Users browsing this forum: SaRaB and 5 guests