• 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!

Legacy GM Multiplayer LAN lobby?

U

Ulrich6

Guest
Hello everyone.

I'm trying to build a multiplayer LAN lobby engine, that works as so:
  • the server (host) broadcasts its IP to everyone in the LAN (presumably through UDP);
  • the clients that want to join a session receive the server's IP;
  • the clients connect to that IP now through TCP.
The problem is that I'm stuck at the part of broadcasting.
Currently, I have:

Server's Create Event:

serverName = "Test";
port = 7676;
server = network_create_server(network_socket_tcp, port, 16);
socket = network_create_socket(network_socket_udp);
broadcast_buffer = buffer_create(1024, buffer_fixed, 1);

Server's Step Event:

buffer_seek(broadcast_buffer, buffer_seek_start, 0);
buffer_write(broadcast_buffer, buffer_string, serverName);
network_send_broadcast(socket, port, broadcast_buffer, buffer_tell(broadcast_buffer));


And:

Client's Create Event:

socket = network_create_socket(network_socket_udp);

Client's Async Networking Event:

var buffer = async_load[? "buffer"];
buffer_seek(buffer, buffer_seek_start, 0);


var serverName = buffer_read(buffer, buffer_string);
show_message(string(serverName));


The problem is that I never get that message telling the server's name in the client.
Maybe I'm doing something bad on sending the packet or receiving it.

Also, there is no such function as network_create_socket_ext() for me, so I'm not able to choose a specific port on UDP.

I have no idea how to broadcast a message (without knowing any IP at the beginning).

Hope you can help me.

Thanks a lot in advance.
 
U

Ulrich6

Guest
I managed to solve the question by carefully reproducing the tutorial/demo "LAN Platformer" that comes with GameMaker: Studio, which shows just that.
Thanks anyway.
 
Top