posted 10 years ago
Hello, I'm learning programming and I'm doing so by writing a program, I chose to write a server and chat client. I'm trying to stick with the MVC model. I have ran into a problem, In my server, I want my packets coming in, to be placed on and event queue. Now I think this is the best way to handle it, because I generate 2 threads for every connection and want to pass packets as events to the main controller. There are a bunch of examples of custom listeners and events using lists. Which I will do, if I can't use a blockingQueue to handle these packets or some form of a queue.
Here are a few questions I have:
1st Is it possible to use a queue? better yet a BlockingQueue?
2nd Can I send a packet from the client to the server (using a serialized packet) which I plan to have extend EventObject, if not, how should I handle this? I plan to have different types of packets don't know if this being passed as an event will create UNKNOWN problems? Example packet plan (if I have it right?)
3rd anyone have a good example of a custom Queue eventListener to help me understand?