Tuesday, 8 November 2011

Java: A Network Application (4)

Aah, had a migraine last night and now I don't. Best feeling ever. So I can happily move on to the NodeListener today, as promised! Meaning tomorrow we have the actual faux-application, then we're done. One day of bullshitting and stuff, then onto actual game stuff.

This is actually a very short class, and it's not ideal, since it uses the Application itself, before it's been created. I just fixed the errors popping up using the automatic stuff Netbeans does. Just created an empty class and method as a placeholder until I actually get around to making the application later tonight.

But hey, it gives a nice little "not implemented" message, so a programmer that even only skims the code will know there's more to go, so it isn't all THAT bad. Here's the entire class, summed up in one screenshot:

See? We need an application for the listener to inform! Maybe I should've done this class last, but it seemed like the right thing to do at the time. Can't be helped!
All this class needs is a Node to listen to and an Application to inform, after that, you just have the thread to run. Lines 14-16 just mean that it's perpetually grabbing a message from the Node (while true = infinite, remember), and when it gets a message, it'll add it to the (so far) not-created Application. And that's it. That's the listener :P

Yay short posts! See you tomorrow for the application itself, and actually running it! Questions and comments welcome!