org.eclipse.jetty.websocket.api.WebSocketException Java Examples
The following examples show how to use
org.eclipse.jetty.websocket.api.WebSocketException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionManager.java From zeppelin with Apache License 2.0 | 6 votes |
public void broadcast(String noteId, Message m) { List<NotebookSocket> socketsToBroadcast = Collections.emptyList(); synchronized (noteSocketMap) { broadcastToWatchers(noteId, StringUtils.EMPTY, m); List<NotebookSocket> socketLists = noteSocketMap.get(noteId); if (socketLists == null || socketLists.size() == 0) { return; } socketsToBroadcast = new ArrayList<>(socketLists); } LOGGER.debug("SEND >> " + m); for (NotebookSocket conn : socketsToBroadcast) { try { conn.send(serializeMessage(m)); } catch (IOException | WebSocketException e) { LOGGER.error("socket error", e); } } }
Example #2
Source File: ConnectionManager.java From zeppelin with Apache License 2.0 | 6 votes |
private void broadcastToWatchers(String noteId, String subject, Message message) { synchronized (watcherSockets) { for (NotebookSocket watcher : watcherSockets) { try { watcher.send( WatcherMessage.builder(noteId) .subject(subject) .message(serializeMessage(message)) .build() .toJson()); } catch (IOException | WebSocketException e) { LOGGER.error("Cannot broadcast message to watcher", e); } } } }
Example #3
Source File: ConnectionManager.java From zeppelin with Apache License 2.0 | 6 votes |
public void broadcastExcept(String noteId, Message m, NotebookSocket exclude) { List<NotebookSocket> socketsToBroadcast = Collections.emptyList(); synchronized (noteSocketMap) { broadcastToWatchers(noteId, StringUtils.EMPTY, m); List<NotebookSocket> socketLists = noteSocketMap.get(noteId); if (socketLists == null || socketLists.size() == 0) { return; } socketsToBroadcast = new ArrayList<>(socketLists); } LOGGER.debug("SEND >> " + m); for (NotebookSocket conn : socketsToBroadcast) { if (exclude.equals(conn)) { continue; } try { conn.send(serializeMessage(m)); } catch (IOException | WebSocketException e) { LOGGER.error("socket error", e); } } }
Example #4
Source File: ConnectionManager.java From submarine with Apache License 2.0 | 5 votes |
public void broadcast(Message m) { synchronized (connectedSockets) { for (NotebookSocket ns : connectedSockets) { try { ns.send(serializeMessage(m)); } catch (IOException | WebSocketException e) { LOG.error("Send error: " + m, e); } } } }
Example #5
Source File: JettyWebSocketSession.java From spring-analysis-note with MIT License | 5 votes |
private RemoteEndpoint getRemoteEndpoint() throws IOException { try { return getNativeSession().getRemote(); } catch (WebSocketException ex) { throw new IOException("Unable to obtain RemoteEndpoint in session " + getId(), ex); } }
Example #6
Source File: JettyWebSocketSession.java From java-technology-stack with MIT License | 5 votes |
private RemoteEndpoint getRemoteEndpoint() throws IOException { try { return getNativeSession().getRemote(); } catch (WebSocketException ex) { throw new IOException("Unable to obtain RemoteEndpoint in session " + getId(), ex); } }
Example #7
Source File: ConnectionManager.java From zeppelin with Apache License 2.0 | 5 votes |
public void broadcast(Message m) { synchronized (connectedSockets) { for (NotebookSocket ns : connectedSockets) { try { ns.send(serializeMessage(m)); } catch (IOException | WebSocketException e) { LOGGER.error("Send error: " + m, e); } } } }
Example #8
Source File: ConnectionManager.java From zeppelin with Apache License 2.0 | 5 votes |
public void broadcastToAllConnectionsExcept(NotebookSocket exclude, String serializedMsg) { synchronized (connectedSockets) { for (NotebookSocket conn : connectedSockets) { if (exclude != null && exclude.equals(conn)) { continue; } try { conn.send(serializedMsg); } catch (IOException | WebSocketException e) { LOGGER.error("Cannot broadcast message to conn", e); } } } }
Example #9
Source File: ConnectionManager.java From zeppelin with Apache License 2.0 | 5 votes |
public void unicast(Message m, NotebookSocket conn) { try { conn.send(serializeMessage(m)); } catch (IOException | WebSocketException e) { LOGGER.error("socket error", e); } broadcastToWatchers(StringUtils.EMPTY, StringUtils.EMPTY, m); }
Example #10
Source File: WebSocketChannelImpl.java From swellrt with Apache License 2.0 | 5 votes |
@Override public void sendMessageString(String data) throws IOException { synchronized (this) { sentMessages.add(data); if (session == null) { LOG.fine("Websocket[" + connectionId + "] is not connected"); } else { try { session.getRemote().sendStringByFuture(data); } catch (WebSocketException e) { LOG.fine("Websocket[" + connectionId + "] send exception: " + e.getMessage()); } } } }
Example #11
Source File: KurentoClientBrowserTest.java From kurento-java with Apache License 2.0 | 5 votes |
@FailedTest public static void retrieveGstreamerDots() { if (kurentoClient != null) { try { List<MediaPipeline> pipelines = kurentoClient.getServerManager().getPipelines(); log.debug("Retrieving GStreamerDots for all pipelines in KMS ({})", pipelines.size()); for (MediaPipeline pipeline : pipelines) { String pipelineName = pipeline.getName(); log.debug("Saving GstreamerDot for pipeline {}", pipelineName); String gstreamerDotFile = KurentoTest.getDefaultOutputFile("-" + pipelineName); try { FileUtils.writeStringToFile(new File(gstreamerDotFile), pipeline.getGstreamerDot()); } catch (IOException ioe) { log.error("Exception writing GstreamerDot file", ioe); } } } catch (WebSocketException e) { log.warn("WebSocket exception while reading existing pipelines. Maybe KMS is closed: {}:{}", e.getClass().getName(), e.getMessage()); } } }
Example #12
Source File: WebSocketJettyServer.java From joynr with Apache License 2.0 | 4 votes |
@Override public synchronized void writeBytes(Address toAddress, byte[] message, long timeout, TimeUnit unit, final SuccessAction successAction, final FailureAction failureAction) { if (!(toAddress instanceof WebSocketClientAddress)) { throw new JoynrIllegalStateException("Web Socket Server can only send to WebSocketClientAddresses"); } WebSocketClientAddress toClientAddress = (WebSocketClientAddress) toAddress; Session session = sessionMap.get(toClientAddress.getId()); if (session == null) { //TODO We need a delay with invalidation of the stub throw new JoynrDelayMessageException("no active session for WebSocketClientAddress: " + toClientAddress.getId()); } try { session.getRemote().sendBytes(ByteBuffer.wrap(message), new WriteCallback() { @Override public void writeSuccess() { successAction.execute(); } @Override public void writeFailed(Throwable error) { if (shutdown) { return; } failureAction.execute(error); } }); } catch (WebSocketException e) { // Jetty throws WebSocketException when expecting [OPEN or CONNECTED] but found a different state // The client must reconnect, but the message can be queued in the mean time. sessionMap.remove(toClientAddress.getId()); //TODO We need a delay with invalidation of the stub throw new JoynrDelayMessageException(e.getMessage(), e); } }