I’m trying to broadcast a message, but I’m getting a NullPointerException:
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
In SelectorKernel.java on line 194:
So it seems that that
thread object is null. What’s going on here?
There’s not enough information here to figure out the problem; how are you setting up your server? Are there any clients connected? How are they connected? Try setting up a test-case independent of your project and see if the problem persists. Also make sure to thoroughly read all of the Wiki’s topics on networking. It’s a very difficult and complex topic, so make sure you’ve read and understood those tutorials and pointers, they help quite a bit.
On a side note, good luck with your networking!
Yeah, as said, we don’t have enough information. We’d have to see your server and client setup code at a minimum.
Most likely is that you haven’t even started the server or you are trying to broadcast to a server that is not fully setup or something. I use the networking all the time (I wrote it after all) and have never once seen this issue… so I’m only guessing.
I moved my server.broadcast call out of the update method of my AppState and into the initialize method instead, now it works.
However, I need to do the broadcast from the update method. I suppose this is a thread issue.
Getting a 502 error on the wiki page atm
@afflicto If your problem was solved, edit the title and add [SOLVED] at the end.
What update() method? initialize() is generally run even earlier than update… but it depends on about 100 things like which update, which initialize.
This game is no fun without seeing code so I’m afraid I’m going to have to stop playing until you provide the proper info. No time for 20 questions today.
I’m talking about AbstractState’s update and initialize methods.
Same state? Different states?
initialize() is called before update()… so if the broadcast succeeds in initialize() but fails in update() of the very same app state then something very strange is going on… or you are calling update yourself for some reason.
…either way, can’t tell without seeing actual code. Networking works in all 5 of my different apps that use it and I’ve never seen this issue.
so, without more information, I’ll sign off… Good luck with your game, though.
Alright, then I know something is wrong after my appState is initialized. I’ll see if I can track it down, if not I’ll post some code for sure, thanks.
It was a stupid bug on my end. I really should take time to organize my code a bit better. Networked games really demand a good architecture.
If there are truer words, I’m not sure I’ve heard them spoken.