Spamming a socket with TextMessage

Hi,it’s me again!

I’m trying to spam requests to server:

[java] if(binding.equals(“Backward”)) {
if(value) {
} else { backward=false; } [/java]

[java] public void requestServerPlayer() {
client.send(new TextMessage(“RequestServerPlayer”));

But this doesn’t work,the “send” method is executed just once and the server so tells me in the console that he sends player stats only one time.

I tried to put requestServerPlayer() in the update() method too,but it gaves me no differences.

Can anyone help me?

You haven’t even close to given us enough code to help.

Edit: I very much assure you that you can spam messages. So the problem is in your code… which you could easily see by running in a debugger or simply putting some System.out.println() statements in.

I feel like this might be that you are usong an action controller for key input, if you want to get events every update that the key is held down then use an analogue controller. The action controller only sends updates when a key is initially pressed or released. But i can only guess, because you have only shown us a very small part of the code.

I tried to make the client send the message in every update and it didn’t work,so i don’t think the controller is the problem.

Also,i tried to put a println() in the function.

[java] System.out.println(“requestsp”);[/java]

It prints me “requestsp” every time but it doesn’t send the message.

The message is getting sent. How many FPS are you getting? ie: how often is the message sent?

Is the message being sent with reliable set to true or to false?

How do you know the server isn’t receiving it? Does it receive only one? Is it crashing? Do you have an error listener setup?

I think that’s probably all of the help I will give without more code.

Ok,i solved.
There was an error on the server listener,thanks everyone for all tips :smiley: