Potatütata
Member
Hello,
I am neither a newbie nor a professional with game maker. Yesterday, I just picked it up again and wanted to learn something about networking. I am still using Game Maker 1.4 but this shouldnt be a big probled, or is it?
I was following a tutorial on youtube from Heart Beast about online multiplayer and it all works fine on my pc with server and client, but as the title states on a different pc in my network the connection fails.
Server Project:
obj_server:
Create event:
Networking Event:
Client Project:
obj_client:
Create event:
Networking Event:
Download Links for the projects:
Client: https://www.dropbox.com/sh/0pakhhmf92onslx/AACwUcW_eufcEA3ciFBQZ3G5a?dl=1
Server: https://www.dropbox.com/sh/91oi7kziorlct99/AADidO7KaeRvMu8SEVtiwp4_a?dl=1
I hope someone can help me.
Best regards
Potatütata / Potatuetata
I am neither a newbie nor a professional with game maker. Yesterday, I just picked it up again and wanted to learn something about networking. I am still using Game Maker 1.4 but this shouldnt be a big probled, or is it?
I was following a tutorial on youtube from Heart Beast about online multiplayer and it all works fine on my pc with server and client, but as the title states on a different pc in my network the connection fails.
Server Project:
obj_server:
Create event:
GML:
/// Initialize the server object
var type = network_socket_tcp;
var port = 8000;
max_clients = 1;
server = network_create_server(type, port, max_clients)
socket = noone;
buffer = buffer_create(9, buffer_grow, 1);
GML:
/// Check for clients and data
var type_event = async_load[? "type"];
switch(type_event) {
case network_type_connect:
// Add the client to the socket variable
if (socket == noone) {
socket = async_load[? "socket"];
show_debug_message(socket);
}
break;
case network_type_disconnect:
// Remove the client from the socket variable
socket = noone;
show_debug_message(socket)
break;
case network_type_data:
// Handle the data
var buffer = async_load[? "buffer"];
buffer_seek(buffer, buffer_seek_start, 0);
scr_received_packet(buffer);
break;
}
Client Project:
obj_client:
Create event:
GML:
/// initialize the client
var type = network_socket_tcp;
var ip = global.server_ip;
var port = 8000;
socket = network_create_socket(type);
network_set_config(network_config_connect_timeout, 4000);
network_set_config(network_config_use_non_blocking_socket, 1);
connection = network_connect(socket, ip, port);
var size = 1024;
var type = buffer_fixed;
var alignment = 1;
buffer = buffer_create(size, type, alignment);
GML:
/// Check for server and data
var type_event = async_load[? "type"];
switch(type_event)
{
case network_type_non_blocking_connect:
// check if connection is possible
var succeeded = ds_map_find_value(async_load, "succeeded");
if succeeded == 0 {
show_message("Could not find server!");
game_restart();
}else {
// send a buffer to request all dot data
var buffer_req = buffer_create(1, buffer_fixed, 1);
buffer_seek(buffer_req, buffer_seek_start, 0);
buffer_write(buffer_req, buffer_u8, 3);
network_send_packet(socket, buffer_req, buffer_tell(buffer_req));
room_goto_next();
}
break;
case network_type_data:
// Handle the data
var buffer = async_load[? "buffer"]
buffer_seek(buffer, buffer_seek_start, 0);
scr_received_packet(buffer);
break;
}
Client: https://www.dropbox.com/sh/0pakhhmf92onslx/AACwUcW_eufcEA3ciFBQZ3G5a?dl=1
Server: https://www.dropbox.com/sh/91oi7kziorlct99/AADidO7KaeRvMu8SEVtiwp4_a?dl=1
I hope someone can help me.
Best regards
Potatütata / Potatuetata