I'm considering to switch to Java, but before I need to know if this is possible with Java or generally with computers and networks.
I want to create a game with a websocket. Lets say 2 players connect to that websocket. After the second player has connected, a thread starts (lets call it thread1) and sends continously (with a few ms delay) messages to both clients. This messages should be send at the exact same time. Not like this:
client.send("bla")
client.send("bla")
1st question: is this possible with computers and networks?
When a client does press a key at the keyboard, I want to send a message to the backend. Lets say both clients press key "A" at the same time and both messages magically enter the backend at the same time.
2nd question: is this theoretically possible that they enter the backend at the exact same time?
If they do enter at the exact same time then two variables (each of them belongs to a user) should be set with the value at the exact same time, not like this:
user1Key = "A";
user2Key = "A";
3rd question: Is this possible?
4th question: If so, what's the name of the "thing" that does help me doing that?
I want do things like that because in thread1 I update the state of each player and they should receive the update theoretically at the same time because it should be fair. And when both have pressed a key at the same time, then it should be impossible that one player gets an advatage because his press was recognized first (user1Key was updated) and then position was updated before user2Key was updated.
This is my first post, please give me some hope, at the moment im pretty lost. I don't know how to find this information. I need feedback from some pros
I want to create a game with a websocket. Lets say 2 players connect to that websocket. After the second player has connected, a thread starts (lets call it thread1) and sends continously (with a few ms delay) messages to both clients. This messages should be send at the exact same time. Not like this:
client.send("bla")
client.send("bla")
1st question: is this possible with computers and networks?
When a client does press a key at the keyboard, I want to send a message to the backend. Lets say both clients press key "A" at the same time and both messages magically enter the backend at the same time.
2nd question: is this theoretically possible that they enter the backend at the exact same time?
If they do enter at the exact same time then two variables (each of them belongs to a user) should be set with the value at the exact same time, not like this:
user1Key = "A";
user2Key = "A";
3rd question: Is this possible?
4th question: If so, what's the name of the "thing" that does help me doing that?
I want do things like that because in thread1 I update the state of each player and they should receive the update theoretically at the same time because it should be fair. And when both have pressed a key at the same time, then it should be impossible that one player gets an advatage because his press was recognized first (user1Key was updated) and then position was updated before user2Key was updated.
This is my first post, please give me some hope, at the moment im pretty lost. I don't know how to find this information. I need feedback from some pros