Created
March 19, 2014 20:36
-
-
Save Ribesg/9650634 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java conception problem: | |
Context: a Java IRC API | |
Problem: Callback* | |
*Term may not be correct, name propositions encouraged | |
When an IRC Packet is sent by the API user, he can choose to have some response handling. | |
The user specifies which IRC packets he would like his Callback to listen. | |
Here's what currently happens when an IRC Packet is received: | |
- Give it to the CallbackHandler | |
- If the CallbackHandler didn't consume it, i.e. no Callback said that she didn't want the Packet to continue to the rest of the Message Handling process, then the IRC Packet is parsed for other things: PINGs are responded with PONGs, JOIN/PARTs are passed to the Client as events, etc. | |
The problem is with Callbacks. When the receive a Packet, they can: | |
- Say they ignored it, that's not the message they were waiting for | |
- Say they used it but the Callback is still waiting for some additional Packets | |
- Say they used it and the Callback should be unregistered and destroyed | |
Now, I planned to have a CallbackResult thing with those 3 possible results, and I don't know what enum value I could use (First one would be IGNORED I think, but I don't know for the 2 others). | |
1) Is it a good design? What may be wrong with it? | |
2) If you think it's a good design, what enum values could I use for the 2 other cases? | |
Thanks for the help. | |
ANNEX: the NAMES command, an example Callback usage | |
- Client sends a NAMES #myChannel command | |
- Server sends ONE OR MORE RPL_NAMREPLY to the Client, each one containing a subset of all the Users in the Channel (Packet size are limited) | |
- Once all RPL_NAMREPLY are sent, the Server send a RPL_ENDOFNAMES packet | |
Here the Callback would have to ignore anything but those 2 replies, add names to a temp list on RPL_NAMREPLY (while staying registered), apply this temp list to the Channel on RPL_ENDOFNAMES, then unregister itself. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment