Legacy GM Buffer error with recieving

R

Rodimus

Guest
Hello!

I have an object named o Client. It connects to the rever without problem.
I have an oServer object, wich is the server, and accepte o Client's connecton without problem.
I want to send packet from the Client, but i I set up the recieving in oServer's Async Networking event the game crush with error "buffer_read argument 1 incorrect type (undefined) expectiong number(YYGI32)".

Thisi s how I set up the server part (FEED_CLIENT is a constant with value 0):

var b = ds_map_find_value(async_load,"buffer");
var cmd = buffer_read(b,buffer_u16);

switch(cmd)
{
case (FEED_CLIENT):
show_debug_message("Hello Too");
break;
}

At this point not even try to send any packet from the client, but the game crashes.

What I do wrong?
 

FrostyCat

Redemption Seeker
This simply means async_load[? "buffer"] doesn't exist, which can happen during connection- and disconnection-type events in a TCP server.

This is why you should always check async_load[? "id"] and async_load[? "type"] before acting upon a Networking event.
 
R

Rodimus

Guest
Ah, yes, I overlooked it, now no error pops up, but my serven not get the packets still.
Client:
tbuffer = buffer_create(256,buffer_grow,1);
buffer_seek(tbuffer,buffer_seek_start,0);
buffer_write(tbuffer,buffer_u16,FEED_CLIENT);
network_send_packet(_client,tbuffer,buffer_tell(tbuffer));
buffer_delete(tbuffer);

Server (Async_Network):
var n_id = ds_map_find_value(async_load, "id");
if n_id == global.server
{
var t = ds_map_find_value(async_load, "type");
switch(t)
{
case network_type_connect:
var sock = ds_map_find_value(async_load, "socket");
ds_list_add(socketlist, sock);
show_debug_message("Connection");
break;
case network_type_disconnect:
var sock = ds_map_find_value(async_load, "socket");
ds_map_delete(socketlist, sock);
break;
case network_type_data:
var b = ds_map_find_value(async_load,"buffer");
var cmd = buffer_read(b,buffer_u16);

switch(cmd)
{
case (FEED_CLIENT):
show_debug_message("Hello Client!");
break;
}
break;

}
}
 
Top