Package org.quickserver.net.server

Examples of org.quickserver.net.server.ClientHandler


        if(QSObjectPool.class.isInstance(objectPool)==false) {
          handler.sendClientMsg("-ERR System Error!");
        }

        ClientIdentifier clientIdentifier = target.getClientIdentifier();
        ClientHandler foundClientHandler = null;
        synchronized(clientIdentifier.getObjectToSynchronize()) { 
          Iterator iterator = clientIdentifier.findAllClient();
          handler.sendClientMsg("+OK info follows");
          while(iterator.hasNext()) {
            foundClientHandler = (ClientHandler) iterator.next();
            handler.sendClientMsg(foundClientHandler.info());
          }
        }
        handler.sendClientMsg(".");
      } else {
        handler.sendClientMsg("-ERR Pool Closed");
View Full Code Here


      String room, String msg) throws SocketTimeoutException,
        IOException {
    if(room==null || msg==null) return;
    Iterator iterator = handler.getServer().findAllClientByKey(
      ".+@"+room);
    ClientHandler toHandler = null;
    if(iterator.hasNext()) {
      while(iterator.hasNext()) {
        if(msg.equals("LoggedOut")==false)
          handler.isConnected();//check if src is still alive
        toHandler = (ClientHandler) iterator.next();
View Full Code Here

    if(j!=command.length())
      message = command.substring(j+1);
    else
      message = "";

    ClientHandler toHandler = null;
    Iterator iterator = null;
    if(id.indexOf("@")!=-1) {
      toHandler = handler.getServer().findClientByKey(id);
      List list = new ArrayList();
      if(toHandler!=null) {
View Full Code Here

      return new NonBlockingClientHandler(id);
  }

  //Uninitialize an instance to be returned to the pool.
    public void passivateObject(Object obj) {
    ClientHandler ch = (ClientHandler)obj;
    ch.clean();
    }
View Full Code Here

    public static final Logger logger = Logger.getLogger(Server.class.getName());
   
    @Override
    public void send(LobbySession key, Message message) {
        ClientHandler ch = getClientHandler(key);
        if (ch!=null) {
            try {

                // TODO we do not give the ByteArrayOutputStream a size, even though we can work it out
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                lobbyServer.encode(out, message);
                byte[] data = out.toByteArray();

                // synchronized does NOT fix the "toNotify object was already set!",
                // and does not really solve any problem or help anything
                //synchronized(ch) {
                    ch.sendClientBinary(data);
                //}
            }
            catch (Exception ex) {
                logger.log(Level.WARNING,"Failed to send "+key+" "+message,ex);
            }
View Full Code Here

        }
    }

    @Override
    public void kick(LobbySession key) {
        ClientHandler ch = getClientHandler(key);
        if (ch!=null) {
            ch.closeConnection();
        }
        else {
            logger.warning("LobbySession: "+key+" NOT FOUND! can not kick");
        }
    }
View Full Code Here

            logger.warning("LobbySession: "+key+" NOT FOUND! can not kick");
        }
    }
    @Override
    public boolean isConnected(LobbySession key) {
        ClientHandler ch = getClientHandler(key);
        if (ch!=null) {
            return ch.isOpen();
        }
        else {
            return false;
        }
    }
View Full Code Here

   * @throws IOException Signals that an I/O exception has occurred.
   */
  public void send(ClientHandler handler, GameRoom room) throws IOException {
    clients = new HashMap<String, Date>();
    Iterator<ClientHandler> iterator = room.getClients().iterator();
    ClientHandler toHandler = null;
    while (iterator.hasNext()) {
      toHandler = (ClientHandler) iterator.next();
      data = (ClientInfo) toHandler.getClientData();
      clients.put(data.getName(), data.getJoinTime());
    }
    iterator = room.getClients().iterator();
    while (iterator.hasNext()){
      toHandler = (ClientHandler) iterator.next();
      toHandler.sendClientObject(new PlayerList(clients));
    }
  }
View Full Code Here

   * @throws IOException Signals that an I/O exception has occurred.
   */
  public void send(ClientHandler handler, GameRoom room) throws IOException {
    @SuppressWarnings("rawtypes")
    Iterator iterator = handler.getServer().findAllClient();
    ClientHandler toHandler = null;
    while (iterator.hasNext()) {
      toHandler = (ClientHandler) iterator.next();
      toHandler.getObjectOutputStream().reset();
      toHandler.sendClientObject(room.getLeaderboard());
    }
  }
View Full Code Here

   * @param room the room
   * @throws IOException Signals that an I/O exception has occurred.
   */
  public void send(ClientHandler handler, GameRoom room) throws IOException {
    Iterator<ClientHandler> iterator = room.getClients().iterator();
    ClientHandler toHandler = null;
    while (iterator.hasNext()) {
      toHandler = (ClientHandler) iterator.next();
      toHandler.getObjectOutputStream().reset();
      toHandler.sendClientObject(room.getGameSheet());

    }
  }
View Full Code Here

TOP

Related Classes of org.quickserver.net.server.ClientHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.