G
GhostlyImprints
Guest
UPDATE:
I've determined that either Java is sending multiple messages at a time in one packet or GameMaker is receiving multiple packets but including them in one buffer in the Async Network event.
I don't know which and I'm currently not sure how to tell.
Each time I write a "message" from my Java server, I'm writing a buffer of 256 bytes. Sometimes GameMaker will see 256 bytes, sometimes it will see 512.
I could simply just read 256 bytes at a time, but I'd like to understand why multiple 256-byte messages are being received in one Async event. I'd also prefer to deal with one 256-byte message at a time instead of parsing through it in one event. Is this possible?
----
I'm trying to have my Java server send multiple packets at a time to GameMaker clients over TCP.
The problem is, sometimes when I send multiple packets at a time, not all of them go through:
The only way I've managed to get all my messages through on GM is to sleep the thread for 100 milliseconds.
I don't know why sleeping the thread is the only way to get all packets received by my GameMaker client's.
Am I doing something wrong?
I've determined that either Java is sending multiple messages at a time in one packet or GameMaker is receiving multiple packets but including them in one buffer in the Async Network event.
I don't know which and I'm currently not sure how to tell.
Each time I write a "message" from my Java server, I'm writing a buffer of 256 bytes. Sometimes GameMaker will see 256 bytes, sometimes it will see 512.
I could simply just read 256 bytes at a time, but I'd like to understand why multiple 256-byte messages are being received in one Async event. I'd also prefer to deal with one 256-byte message at a time instead of parsing through it in one event. Is this possible?
----
I'm trying to have my Java server send multiple packets at a time to GameMaker clients over TCP.
The problem is, sometimes when I send multiple packets at a time, not all of them go through:
Java:
// Send all player's information to everyone else
outerPlayerIter = players.iterator();
while(outerPlayerIter.hasNext()) {
Player outerPlayer = outerPlayerIter.next();
Iterator<Player> innerPlayerIter = players.iterator();
while(innerPlayerIter.hasNext()) {
Player innerPlayer = innerPlayerIter.next();
boolean isYou = false;
if(innerPlayer.equals(outerPlayer)) isYou = true;
// Send innerPlayer's info to outerPlayer
Thread.sleep(100);
dataBuffer.clearBuffer();
dataBuffer.writeByte(Msgs.mm_toclient.MES_SENDPLAYERINFO);
dataBuffer.writeBool(isYou);
dataBuffer.writeBool(innerPlayer.getIsHost());
dataBuffer.writeString(innerPlayer.getName());
dataBuffer.writeString(innerPlayer.getPublicIP().getHostAddress());
dataBuffer.writeShort((short)innerPlayer.getUdpPort());
outerPlayer.getSocket().getOutputStream().write(dataBuffer.getByteArray());
outerPlayer.getSocket().getOutputStream().flush();
}
}
I don't know why sleeping the thread is the only way to get all packets received by my GameMaker client's.
Am I doing something wrong?
Last edited by a moderator: