yesterday i posted a question on how i could use StreamReader WITHOUT letting unity crash.... i taken out the loop BUT theres still some weird stuff
when i start the server (a java server) en connect to it in unity, the game not freezes but it WAITS for a newline (because i use ReadLine()), wether i use ReadLine(); or Read(); it doesn't matter, it always freezes.
i just discoverd that when i send something to unity using the server, unity rendered 1 frame then freezes again. unity waits until it receives data before moving on with the other things.
i tried the things told i must do to make it work but, either i didn't do what was said, or it didn't work.
i hope to finally hear a solution to this, because im already searched for this 3 days in a row now and i can't move on before i found an awnser
Script:
void Read() {
NetworkStream STREAM = connection.GetStream();
string line = null;
StreamReader IN = new StreamReader(STREAM);
String returndata = IN.ReadLine();
string[] returndata2 = returndata.Split(" "[0]);
string code = returndata2[0];
string text = returndata.Replace(code, "");
if(code == "#ChatMessage") {
BroadcastMessage("AddChatMessage", text);
}
}
void Update () {
Read();
}
↧