Package org.auto.comet.support

Source Code of org.auto.comet.support.LocalSocketStore

package org.auto.comet.support;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.auto.comet.PushSocket;
import org.auto.comet.Socket;

/**
* @author XiaohangHu
* */
public class LocalSocketStore implements SocketStore {

  private Map<Serializable, PushSocket> sockets;
  {
    this.sockets = new HashMap<Serializable, PushSocket>();
  }

  public PushSocket getSocket(Serializable id) {
    return this.sockets.get(id);
  }

  public PushSocket removeSocket(Serializable id) {
    return this.sockets.remove(id);
  }

  public void addSocket(PushSocket socket) {
    this.sockets.put(socket.getId(), socket);
  };

  public boolean hasSocket(Serializable id) {
    Socket socket = this.getSocket(id);
    return null != socket;
  }

  public Collection<PushSocket> getAllSocket() {
    return this.sockets.values();
  }

}
TOP

Related Classes of org.auto.comet.support.LocalSocketStore

TOP
Copyright © 2018 www.massapi.com. 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.