Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MessageManager
- {
- private Message lastMessage = null;
- private Network net;
- public MessageManager(Network net)
- {
- this.net = net;
- }
- private boolean send(Message m)
- {
- try
- {
- net.sendMessage(m);
- lastMessage = null;
- return true;
- }
- catch(IOException e)
- {
- lastMessage = m;
- return false;
- }
- }
- public void run()
- {
- if (lastMessage != null)
- {
- if (!send(lastMessage))
- return;
- }
- while (net.hasMessageAvailable())
- {
- if (!send(net.readNextMessage()))
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement