package com.ifast.websocket;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import javax.sql.rowset.JoinRowSet;
import javax.websocket.EncodeException;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.apache.logging.log4j.message.EntryMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.ifast.Enum.RespEnum;
import com.ifast.requestDTO.ConnectDTO;
import com.ifast.requestDTO.Message;
import com.ifast.requestDTO.ResponseDTO;
import com.ifast.util.JSONUtils;
import com.ifast.util.ToolUtil;
import com.ifast.util.YCResponse;
@Component
@ServerEndpoint(value = “/websocket”)
public class CustomWebSocket {
/*静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。/
private static int onlineCount = 0;
/*concurrent包的线程安全Set,用来存放每个客户端对应的CumWebSocket对象。/
private static CopyOnWriteArraySet webSocketSet = new CopyOnWriteArraySet();
/*与某个客户端的连接会话,需要通过它来给客户端发送数据/
private Session session;
/**
* 此map作为userId与Session的连接
*/
public static final ConcurrentHashMap