@Override
 public void buddyChat(int[] recipientCharacterIds, int cidFrom, String nameFrom, String chattext)
     throws RemoteException {
   for (ChannelWorldInterface cwi : WorldRegistryImpl.getInstance().getAllChannelServers()) {
     cwi.buddyChat(recipientCharacterIds, cidFrom, nameFrom, chattext);
   }
 }
Ejemplo n.º 2
0
  // multi-purpose function that reaches every member of guild (except the character with
  // exceptionId) in all channels with as little access to rmi as possible
  public final void broadcast(final MaplePacket packet, final int exceptionId, final BCOp bcop) {
    final WorldRegistryImpl wr = WorldRegistryImpl.getInstance();
    final Set<Integer> chs = wr.getChannelServer();

    lock.lock();
    try {
      buildNotifications();

      try { // now call the channelworldinterface
        for (final Integer ch : chs) {
          final ChannelWorldInterface cwi = wr.getChannel(ch);
          if (notifications.get(ch).size() > 0) {
            if (bcop == BCOp.DISBAND) {
              cwi.setGuildAndRank(notifications.get(ch), 0, 5, exceptionId);
            } else if (bcop == BCOp.EMBLEMCHANGE) {
              cwi.changeEmblem(id, notifications.get(ch), new MapleGuildSummary(this));
            } else {
              cwi.sendPacket(notifications.get(ch), packet, exceptionId);
            }
          }
        }
      } catch (RemoteException re) {
        System.err.println("Failed to contact channel(s) for broadcast." + re);
      }
    } finally {
      lock.unlock();
    }
  }
 // TODO only notify channels where partymembers are?
 public void updateParty(int partyid, PartyOperation operation, MaplePartyCharacter target)
     throws RemoteException {
   MapleParty party = WorldRegistryImpl.getInstance().getParty(partyid);
   if (party == null) {
     throw new IllegalArgumentException("no party with the specified partyid exists");
   }
   switch (operation) {
     case JOIN:
       party.addMember(target);
       break;
     case EXPEL:
     case LEAVE:
       party.removeMember(target);
       break;
     case DISBAND:
       WorldRegistryImpl.getInstance().disbandParty(partyid);
       break;
     case SILENT_UPDATE:
     case LOG_ONOFF:
       party.updateMember(target);
       break;
     default:
       throw new RuntimeException("Unhandeled updateParty operation " + operation.name());
   }
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.updateParty(party, operation, target);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
 public void declineChat(String target, String namefrom) throws RemoteException {
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.declineChat(target, namefrom);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
 public void broadcastMessage(String sender, byte[] message) throws RemoteException {
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.broadcastMessage(sender, message);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
 public void loggedOn(String name, int characterId, int channel, int[] buddies)
     throws RemoteException {
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.loggedOn(name, characterId, channel, buddies);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
 public void whisper(String sender, String target, int channel, String message)
     throws RemoteException {
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.whisper(sender, target, channel, message);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
 public void messengerInvite(String sender, int messengerid, String target, int fromchannel)
     throws RemoteException {
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.messengerInvite(sender, messengerid, target, fromchannel);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
 public void serverReady() throws RemoteException {
   ready = true;
   for (LoginWorldInterface wli : WorldRegistryImpl.getInstance().getLoginServer()) {
     try {
       wli.channelOnline(cb.getChannelId(), cb.getIP());
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterLoginServer(wli);
     }
   }
   log.info("Channel {} is online.", cb.getChannelId());
 }
Ejemplo n.º 10
0
 @Override
 public CharacterIdChannelPair[] multiBuddyFind(int charIdFrom, int[] characterIds)
     throws RemoteException {
   List<CharacterIdChannelPair> foundsChars =
       new ArrayList<CharacterIdChannelPair>(characterIds.length);
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     for (int charid : cwi.multiBuddyFind(charIdFrom, characterIds)) {
       foundsChars.add(new CharacterIdChannelPair(charid, i));
     }
   }
   return foundsChars.toArray(new CharacterIdChannelPair[foundsChars.size()]);
 }
Ejemplo n.º 11
0
 public String getIP(int channel) throws RemoteException {
   ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(channel);
   if (cwi == null) {
     return "0.0.0.0:0";
   } else {
     try {
       return cwi.getIP();
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(channel);
       return "0.0.0.0:0";
     }
   }
 }
Ejemplo n.º 12
0
 public boolean isConnected(String charName) throws RemoteException {
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       if (cwi.isConnected(charName)) {
         return true;
       }
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
   return false;
 }
Ejemplo n.º 13
0
 public List<CheaterData> getCheaters() throws RemoteException {
   List<CheaterData> allCheaters = new ArrayList<CheaterData>();
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       allCheaters.addAll(cwi.getCheaters());
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
   Collections.sort(allCheaters);
   return CollectionUtil.copyFirst(allCheaters, 10);
 }
Ejemplo n.º 14
0
 public WorldLocation getLocation(String charName) throws RemoteException {
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       if (cwi.isConnected(charName)) {
         return new WorldLocation(cwi.getLocation(charName), cwi.getChannelId());
       }
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
   return null;
 }
Ejemplo n.º 15
0
  public void updateMessenger(int messengerid, String namefrom, int fromchannel)
      throws RemoteException {
    MapleMessenger messenger = WorldRegistryImpl.getInstance().getMessenger(messengerid);
    int position = messenger.getPositionByName(namefrom);

    for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
      ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
      try {
        cwi.updateMessenger(messenger, namefrom, position, fromchannel);
      } catch (RemoteException e) {
        WorldRegistryImpl.getInstance().deregisterChannelServer(i);
      }
    }
  }
Ejemplo n.º 16
0
 // can we generify this
 @Override
 public int find(int characterId) throws RemoteException {
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       if (cwi.isConnected(characterId)) {
         return cwi.getChannelId();
       }
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
   return -1;
 }
Ejemplo n.º 17
0
 public void messengerChat(int messengerid, String chattext, String namefrom)
     throws RemoteException {
   MapleMessenger messenger = WorldRegistryImpl.getInstance().getMessenger(messengerid);
   if (messenger == null) {
     throw new IllegalArgumentException("No messenger with the specified messengerid exists");
   }
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.messengerChat(messenger, chattext, namefrom);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
Ejemplo n.º 18
0
 @Override
 public void partyChat(int partyid, String chattext, String namefrom) throws RemoteException {
   MapleParty party = WorldRegistryImpl.getInstance().getParty(partyid);
   if (party == null) {
     throw new IllegalArgumentException("no party with the specified partyid exists");
   }
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.partyChat(party, chattext, namefrom);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
Ejemplo n.º 19
0
 public Map<Integer, Integer> getConnected() throws RemoteException {
   Map<Integer, Integer> ret = new HashMap<Integer, Integer>();
   int total = 0;
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       int curConnected = cwi.getConnected();
       ret.put(i, curConnected);
       total += curConnected;
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
   ret.put(0, total);
   return ret;
 }
Ejemplo n.º 20
0
 public void shutdown(int time) throws RemoteException {
   for (LoginWorldInterface lwi : WorldRegistryImpl.getInstance().getLoginServer()) {
     try {
       lwi.shutdown();
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterLoginServer(lwi);
     }
   }
   for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
     ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
     try {
       cwi.shutdown(time);
     } catch (RemoteException e) {
       WorldRegistryImpl.getInstance().deregisterChannelServer(i);
     }
   }
 }
Ejemplo n.º 21
0
  public void joinMessenger(
      int messengerid, MapleMessengerCharacter target, String from, int fromchannel)
      throws RemoteException {
    MapleMessenger messenger = WorldRegistryImpl.getInstance().getMessenger(messengerid);
    if (messenger == null) {
      throw new IllegalArgumentException("No messenger with the specified messengerid exists");
    }
    messenger.addMember(target);

    for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
      ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
      try {
        cwi.addMessengerPlayer(messenger, from, fromchannel, target.getPosition());
      } catch (RemoteException e) {
        WorldRegistryImpl.getInstance().deregisterChannelServer(i);
      }
    }
  }
Ejemplo n.º 22
0
  public void leaveMessenger(int messengerid, MapleMessengerCharacter target)
      throws RemoteException {
    MapleMessenger messenger = WorldRegistryImpl.getInstance().getMessenger(messengerid);
    if (messenger == null) {
      throw new IllegalArgumentException("No messenger with the specified messengerid exists");
    }
    int position = messenger.getPositionByName(target.getName());
    messenger.removeMember(target);

    for (int i : WorldRegistryImpl.getInstance().getChannelServer()) {
      ChannelWorldInterface cwi = WorldRegistryImpl.getInstance().getChannel(i);
      try {
        cwi.removeMessengerPlayer(messenger, position);
      } catch (RemoteException e) {
        WorldRegistryImpl.getInstance().deregisterChannelServer(i);
      }
    }
  }