[Socket.io] Players coordinates

Get help using Construct 2

Post » Fri Jul 19, 2013 2:16 pm

[QUOTE=breackzin] [QUOTE=Vladoss] [QUOTE=breackzin]
Every 0,05 seconds:>Send ("alldata," & "," & id & "," & x & "," & y)
[/QUOTE]
For the server part or a client? I'm a little misunderstood.

If I will send some kind of data to the server, how can I split it[/QUOTE]

Your client. You gonna delete the pick, the "is moving?" condition and put a clear "every 0,05"... as I said.

The server side gonna be something like this:

socket.on("message", function (data) {
var new_data = data.split(',');
        if (new_data[0] == 'alldata') {
            id = new_data[1];
            x = new_data[2];
            y = new_data[3];
            
            socket.broadcast.emit("message",
              'alldata,' + id + ',' + x + ',' + y);
        }
[/QUOTE]

Alright. Thank you.

Also, how "socket.broadcast.emit" is different from "socket.send"?

@breackzinVladoss2013-07-19 14:41:30
B
39
S
16
G
6
Posts: 238
Reputation: 7,875

Post » Fri Jul 19, 2013 4:07 pm

@Vladoss
broadcast Sends the message or event to every connected user in the current namespace, except to your self.
It is useful to get off some "picks" from your client code.

send, sends to everyone but does not support custom events.
emit, does support.

Also, my problem is here: http://www.scirra.com/forum/socketio-and-heroku_topic71952.html?KW=breackzin2013-07-20 15:00:57
B
7
S
3
G
1
Posts: 154
Reputation: 1,812

Previous

Return to How do I....?

Who is online

Users browsing this forum: MAVERICK, QuantumMMX and 12 guests