Ejemplo n.º 1
0
 public boolean newPlayerClient(Client client1) {
   int slot = -1;
   for (int i = 1; i < Config.MAX_PLAYERS; i++) {
     if (players[i] == null || players[i].disconnected) {
       slot = i;
       break;
     }
   }
   if (slot == -1) return false;
   client1.handler = this;
   client1.playerId = slot;
   players[slot] = client1;
   players[slot].isActive = true;
   players[slot].connectedFrom =
       ((InetSocketAddress) client1.getSession().getRemoteAddress()).getAddress().getHostAddress();
   if (Config.SERVER_DEBUG)
     Misc.println(
         "Player Slot "
             + slot
             + " slot 0 "
             + players[0]
             + " Player Hit "
             + players[
                 slot]); // does nothing.... ;;players dont give the right amount of playesr? i am
   // getting the right amount why not me? logout log inand u wont get the
   // right
   return true;
 }
Ejemplo n.º 2
0
    @Override
    public void actionPerformed(ActionEvent e) {
      // TODO Auto-generated method stub

      if (testInfo()) {
        System.out.println("Log in successful, Welcome!");
        Client client = new Client(userName.getText(), passWord.getText());
        try {
          TextMessage textmessage = client.getSession().createTextMessage();
          textmessage.setText(" ");
          textmessage.setJMSCorrelationID(userName.getText());
          textmessage.setJMSReplyTo(client.getSession().createQueue(userName.getText()));
          System.out.println(userName.getText());
          client.getProducer().send(Chatwindow.server.getServerTopic(), textmessage);
        } catch (JMSException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
      }
    }
Ejemplo n.º 3
0
 public boolean newPlayerClient(Client client1) {
   int slot = -1;
   for (int i = 1; i < Config.MAX_PLAYERS; i++) {
     if ((players[i] == null) || players[i].disconnected) {
       slot = i;
       break;
     }
   }
   if (slot == -1) return false;
   client1.handler = this;
   client1.playerId = slot;
   players[slot] = client1;
   players[slot].isActive = true;
   players[slot].connectedFrom =
       ((InetSocketAddress) client1.getSession().getRemoteAddress()).getAddress().getHostAddress();
   if (Config.SERVER_DEBUG)
     Misc.println(
         "Player Slot " + slot + " slot 0 " + players[0] + " Player Hit " + players[slot]);
   return true;
 }