List of usage examples for javax.websocket Session getId
String getId();
From source file:fr.feedreader.websocket.UpdateFeed.java
public static void notifyUpdateFeed(Map<Feed, List<FeedItem>> newFeedItem, Map<Feed, Long> countUnread) { LogManager.getLogger().info("notification de mise jour de flux"); ObjectMapper mapper = new ObjectMapper(); FeedUpdateWrapper feedUpdateWrapper = new FeedUpdateWrapper(newFeedItem, countUnread); try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { mapper.writeValue(baos, feedUpdateWrapper); String jsonResponse = baos.toString("UTF-8"); availableSession.iterator();/*from w w w.ja v a 2 s .c o m*/ for (Iterator<Session> it = availableSession.iterator(); it.hasNext();) { Session session = it.next(); try { session.getBasicRemote().sendText(jsonResponse); LogManager.getLogger().info("Envoyer \"" + session.getId() + "\""); } catch (ClosedChannelException ex) { LogManager.getLogger().error( "Session \"" + session.getId() + "\" Fermer. Exclusion de la liste des session active"); it.remove(); } catch (IOException ex) { LogManager.getLogger().error("Erreur dans l'envoi la websocket : " + session.getId(), ex); } } } catch (IOException ioe) { LogManager.getLogger().error("Impossible de convertir les flux mis jour en json", ioe); } }
From source file:org.jboss.as.quickstarts.websocket_hello.HelloName.java
@OnOpen public void helloOnOpen(Session session) { System.out.println("WebSocket opened: " + session.getId()); }
From source file:DataReceiverEndpoint.java
public void onError(Session session, Throwable throwable) { log.error("Error occurred in session ID: " + session.getId() + ", for request URI - " + session.getRequestURI() + ", " + throwable.getMessage(), throwable); }
From source file:de.tuttas.websockets.ChatServer.java
@OnOpen public void onOpen(Session session) { Log.d(session.getId() + " has opened a connection"); sessions.add(session);/*from w w w . j av a2 s . c om*/ mySession = session; ChatLine l = new ChatLine("System", ""); users.put(session.getId(), "NN"); try { session.getBasicRemote().sendText(l.toJson()); } catch (IOException ex) { Logger.getLogger(ChatServer.class.getName()).log(Level.SEVERE, null, ex); } Log.d("Total Number of Clients =" + sessions.size()); }
From source file:de.tuttas.websockets.ChatServer.java
@OnClose public void onClose(Session session) { Log.d("Session " + session.getId() + " has ended user is " + users.get(session.getId())); JSONObject jo = new JSONObject(); jo.put("from", users.get(session.getId())); jo.put("msg", "hat das System verlassen!"); jo.put("notoast", true); send(jo, session);//from w w w . j a va 2s . c o m users.remove(session.getId()); sessions.remove(session); }
From source file:com.cosplay.websocket.IoWebsocket.java
@OnOpen public void start(Session session) { this.session = session; System.out.println("session id :" + session.getId()); }
From source file:hu.bme.iit.quiz.endpoint.IndexEndpoint.java
@OnClose public void onClose(Session peer) { logger.debug("Peer disconnected :: " + peer.getId()); // String deleted = quizzesInGatheringPhase.remove(users.get(peer)); // users.remove(peer); peers.remove(peer);//ww w . j a va2s .c om // if(deleted != null) // sendUpdate(); }
From source file:org.jboss.aerogear.sync.server.wildfly.SyncEndpoint.java
@OnOpen public void onOpen(Session session) { logger.info("WebSocket opened: " + session.getId()); }
From source file:hu.bme.iit.quiz.endpoint.IndexEndpoint.java
@OnOpen public void onOpen(Session peer) { peers.add(peer);//w w w . j a v a 2 s .c o m logger.debug("Peer connected: " + peer.getId() + "; Total peer number: " + peers.size() + "; Quizzes: " + quizzesInGatheringPhase.size()); EndpointUtil.sendUpdateToPeer(peer, createGatheringQuizzesUpdateString()); }
From source file:TopicSubscriptionEndpoint.java
public void onError(Session session, Throwable throwable, String topic, String adaptorName, int tenantId) { log.error("Error occurred in session ID: " + session.getId() + ", for request URI - " + session.getRequestURI() + ", " + throwable.getMessage(), throwable); websocketLocalOutputCallbackRegisterService.unsubscribe(tenantId, adaptorName, topic, session); }