• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

need help udp server

FoufaDjo

Member
my server send data only to my last active client and idk why here is my code:
server creat event:
var type = network_socket_udp;
var port = 8000;

socket = network_create_socket_ext(type,port);
remote_port = 0;
remote_ip = "0.0.0.0";

var type = buffer_grow;
var alignment = 1;
send_buffer = buffer_create(1,type,alignment);



server network Async:
remote_port = async_load[? "port"];
remote_ip = string(async_load[? "ip"]);

var buffer = ds_map_find_value(async_load,"buffer");
var socket = ds_map_find_value(async_load,"id");
buffer_seek(buffer, buffer_seek_start,0);
scr_server(buffer,socket);



scr_server:
var buffer = argument[0];
var socket = argument[1];

var message_id = buffer_read(buffer, buffer_u8);

switch(message_id){
case network.movement:
var op = buffer_read(buffer,buffer_u8);
var target = -10;
with oplayer{
if p = op{
var target = id;
}
}
var i = 0;
repeat(ds_list_size(socket_list)){
var sock = ds_list_find_value(socket_list,i);
buffer_seek(send_buffer, buffer_seek_start,0);
buffer_write(send_buffer, buffer_u8,network.position);
buffer_write(send_buffer, buffer_u8,op);
buffer_write(send_buffer, buffer_s16,target.x);
buffer_write(send_buffer, buffer_s16,target.y);
network_send_udp(sock,remote_ip,remote_port,send_buffer,buffer_tell(send_buffer));
i ++;
}
break;
}
 
Last edited:
Top