Skip to main content
gamedev.net
🔒 Locked

[java] Non-blocking for chating...

Started by ZinkForb 4 replies 700+ views
Original Post
ZinkForb
ZinkForb
Im working on a small MMO and im currently working on the chat part of it. At one point it assigns string input to entered text ex. input = keyboardReader.readLine(); (keyboardReader is a BufferedReader as seen here-BufferedReader keyboardReader = null-) the only problem with this is its in the game loop with the render method and this command is blocking so while it waits for user input it stalls the screen and dosent redraw it with the npc/pc''s movement. So if anyone knows a non-blocking command or another wayto do this let me know plz. thanks
--------------------------"...let the wookie win."What seems to be the officer problem?
aidan_walsh
aidan_walsh
Wouldn''t it be advisable to give the render method a loop of its own in a seperate thread when your dealing with real-time games?


SketchSoft OFFLINE | SketchNews OFFLINE | NewKlear Studios

www.aidanwalsh(.net)(.info)
ZinkForb
ZinkForb
well ok...but how would i do that (im sorda new to java [and have a very bad book on it that dosnt really explain it]) i mean can i have two threads running at once (i prbly sound like a moron) and if so how?
--------------------------"...let the wookie win."What seems to be the officer problem?
nonnus29
nonnus29
quote:
Original post by doodle_sketch
Wouldn't it be advisable to give the render method a loop of its own in a seperate thread when your dealing with real-time games?



No that would be a terrible idea; dealing with synchonization issues would take 100x more time and effort.

I'd say implement KeyListener and implement your own character buffer somewhere. Or only get text from the text area when the 'enter' key is pressed.



[edited by - nonnus29 on May 12, 2004 6:10:26 PM]
CaptainJester
CaptainJester
quote:
Original post by nonnus29
No that would be a terrible idea; dealing with synchonization issues would take 100x more time and effort.

I''d say implement KeyListener and implement your own character buffer somewhere. Or only get text from the text area when


nonnus is right. Have a TextField for the chat entry and when the user hits enter, then read it and transfer it to the network.

Also, the best place to start learning Java is The Java Tutorial. After that you can look at the rest of the specialized tutorials on Sun''s Java site



First make it work, then make it fast. --Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
ZinkForb
ZinkForb
Thanks guys
cause i tried giving it its own thread and it didnt really like it much less even notice it

I really apperciate it cause ive been working on just getting the users input for like 2 days now and it was getting old i knew there was an easier day to do it so thanks again
--------------------------"...let the wookie win."What seems to be the officer problem?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.