I make an application using websockets and Singleton from javax-inject. However for every new websocket session new hash map is created. What should I do to create a mutual map for all sessions?
import javax.inject.Singleton;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ServerEndpoint(value = "/game_endpoint")
@Singleton
public class WaterWorldGame {
Map<Session, Player> players = new HashMap<>();
...
}
Is there any annotations in javax-inject or it would be easier to make it with Spring?
Aucun commentaire:
Enregistrer un commentaire