GML [Solved] Server doesn't allow the client to send it data? Or client doesn't send the data?

X

XirmiX

Guest
Previously, I encountered an issue where the client wasn't sending any information to the server. Apparently, the server needed to give permission to the client for sending data to it once the client was connected. Worked fine for the sending of initial data, and though I was a bit butt-hurt, it didn't create me much problems.

However now, when I need to have the client send data to the server constantly (i.e. the position of the client's player object and its direction every time it changes), this becomes a problem. I have everything set up for the client to send this data, but I have no way of getting permission from the server to allow me to send that data to it. And how would I? How would the server know I am moving my player object to allow me to send information about my player object moving, if the server can't know whether my player object is moving without me sending it data about my player object moving. A bit of a mouthful?

Well, in short terms, there is no way for the client to send the server data without it giving the client permission to do so, but to give it permission to do so is impossible if the server doesn't know whether the client's object is moving or not, which it can't if it doesn't allow the client to send it this information in the first place.

A solution to this would be to make it so that once the player has connected and all the normal data has been confirmed, the server just gives permission to the client to send data over and over again. I'm not sure if I have done this correctly though. I have a system where the server gives permission to the client to send some information to it once the client connects. The client then sends initial information to the server about itself and then the server processes it and does what it needs to do (i.e. spawning a representation of the player object in the correlating place for itself, which it does do!).

Except, I added to this processing one more thing now, and that being the permission from the server to the client that the client can keep sending coordinates and the angle direction of its controllable object to the server (I do have cases for the server to process this information too). I think what might be the problem here is that the server only gives permission once, but it needs to keep sending it, so some form of loop in some way would need to be done, may be, although I'm not entirely sure.

Here's the code for where the server sends permission to the client (this is inside a larger piece of code, though I know that the server does reach this piece of code, since above this is where the server actually spawns in a representation of the player's object for itself in its room):
Code:
//create a buffer with which to send information
                var permission_buffer = buffer_create(256, buffer_fixed, 1);
              
                //writing data to send to buffer
                buffer_seek(permission_buffer, buffer_seek_start, 0);
                buffer_write(permission_buffer, buffer_u8, 1);
              
                network_send_packet(client_socket_current, permission_buffer, buffer_get_size(permission_buffer));
              
                buffer_delete(permission_buffer);
This is where the client processes the information, and based on whether it changes position and direction (which is determined by buffer_type_send, ), it is supposed to send to the server this information:
Code:
type = async_load[? "type"];

switch(type)
{
    case network_type_data:
    buffer = async_load[? "buffer"];
  
    buffer_seek(buffer, buffer_seek_start, 0);
    permission_confirmed = buffer_read(buffer, buffer_u8);
  
    switch(permission_confirmed)
    {
        case 1:
            if (buffer_type_send == 6)
            {
                send_buffer = buffer_create(256, buffer_fixed, 1);
              
                buffer_seek(send_buffer, buffer_seek_start, 0);
                buffer_write(send_buffer, buffer_u8, 6);
                buffer_write(send_buffer, buffer_f32, mytank.x);
                buffer_write(send_buffer, buffer_f32, mytank.y);
              
                network_send_packet(socket_plug, send_buffer, buffer_get_size(send_buffer));
              
                buffer_delete(send_buffer);
            }
          
            if (buffer_type_send == 7)
                {
                send_buffer = buffer_create(256, buffer_fixed, 1);
              
                buffer_seek(send_buffer, buffer_seek_start, 0);
                buffer_write(send_buffer, buffer_u8, 7);
                buffer_write(send_buffer, buffer_f32, mytank.direction);
              
                network_send_packet(socket_plug, send_buffer, buffer_get_size(send_buffer));
              
                buffer_delete(send_buffer);
            }
        break;
    }
Then, the server is supposed to process that information, apply this to its own player-representation object (and send it to other clients too, but that's not of importance right now):
Code:
//sending buffer type 6 (coordinates)
            case 6:
                var client_id = ds_map_find_value(socket_map, client_socket_current);
              
                var xx = buffer_read(buffer, buffer_f32);
                var yy = buffer_read(buffer, buffer_f32);
              
                client_socket_current.instance.x = xx;
                client_socket_current.instance.y = yy;
              
                --[code for sending this information about the client who sent this to the server, to other clients]--
            break;
          
            //sending buffer type 7 (angles)
            case 7:
                var client_id = ds_map_find_value(socket_map, client_socket_current);
              
                var angle = buffer_read(buffer, buffer_f32);
              
                client_socket_current.instance.direction = angle;
              
                --[code for sending this information about the client who sent this to the server, to other clients]--
            break;
Except, though I see my object move around on the client, on the server this does not happen. May be it's because the server is frozen while I have selected the player? Because I do get this in the log:

Pause event has been registered for this frame
Pause event has been unregistered

Though, since the object spawns on the server side as well, even though being frozen and simply doesn't move, I don't think that's the case.
 
X

XirmiX

Guest
Please? Somebody? Anybody? Even if you just put your thoughts on what the issue might be? I just need to be clued in on what's happening, I might probably be able to fix it myself if I just get an idea of what I'm doing wrong here.
 

Tthecreator

Your Creator!
So about this "permission", how are you preventing the client from sending the data on the server side?
I mean security wise?
What you could do is have a special kind of package send from the client, that circumvents all permission measures that just tells the server that it's (the client) ready.
I see you already have some package coding system that makes sure the server knows what it's talking about. So you will have to make it tie into that.
 
X

XirmiX

Guest
So about this "permission", how are you preventing the client from sending the data on the server side?
I mean security wise?
What you could do is have a special kind of package send from the client, that circumvents all permission measures that just tells the server that it's (the client) ready.
I see you already have some package coding system that makes sure the server knows what it's talking about. So you will have to make it tie into that.
Nnnnnooope! I assumed that the permission thing is integrated into the game engine or some 💩💩💩💩, because, the client wasn't sending ANYTHING to the server until I put a permission system in. The way it works is, once a client connects, the server sends a digit to the client, saying "yes you can send stuff to me". And it worked. Before, I didn't have this, and the stuff was meant to be sent if a variable was true or a specific number. Didn't work. Same thing now, except the permission system is in, though it's not being sent constantly, which I think for some reason is needed.

If the permission system isn't needed, then tell me what is needed and why the hell client can't send stuff to the server without this system, but with it, it can? If you want, I can put a copy of my projects (the server and client are handled under two projects) in dropbox and you can have a look at the code, though, that might take a little bit.
 

Tthecreator

Your Creator!
well I'd like your option of sending the project, but for now I'd rather have you try to recreate the issue in an empty project, so we can focus on that more easily.
I can't imagine the gm engine doing something like that.
Assuming you are testing the server and clients all on your local machine, your firewall shouldn't technically be an issue. But disabling it can never hurt.
 
X

XirmiX

Guest
Well, I have the permission thing going already, might as well keep it. But regardless... the project is ALREADY an empty project in and of itself. It can't get any more empty than it already is! The gameplay I'll be putting inside it is in a completely different project which I'll be porting, but right now it's bare bones. Here are the files.

Try running the server, then the client. Move around with arrow keys and witness that the object moves for the client, but not for the server, despite spawning for both the client and the server.
 

Tthecreator

Your Creator!
I'm looking at your project file and I'm seeing some weird things.
You are putting some send things into the networking event, which I think would fit way better in the step event.
Remember: The networking event is only for receiving data and it will only fire when actual data is coming in.
You can send data from any other event in the game, you shouldn't be in the networking event for that.
Maybe you can put the code for your position changes in the step event so it will run every step.
 
X

XirmiX

Guest
I'm looking at your project file and I'm seeing some weird things.
You are putting some send things into the networking event, which I think would fit way better in the step event.
Remember: The networking event is only for receiving data and it will only fire when actual data is coming in.
You can send data from any other event in the game, you shouldn't be in the networking event for that.
Maybe you can put the code for your position changes in the step event so it will run every step.
You can use step event, or any other event for that matter to send buffers?! I had no idea! Thank you, this actually solves my issue :D

I'll take this into account in the future.
 
Top