/** * Send a stop message to server as result of user request. */ public void sendMessage( StopMessage stopMessage ) throws KettleException { sessionValid(); try { if ( !alReadySendedStopMessage.getAndSet( true ) ) { this.userSession.getBasicRemote().sendObject( stopMessage ); } } catch ( Exception e ) { throw new KettleException( e ); } }
public static void sendAll(Message message) { try { /* Send updates to all open WebSocket sessions */ for (Session session : users.values()) { session.getBasicRemote().sendObject(message); logger.info("SendAll: {}", message); } } catch (IOException e) { logger.error(e.toString()); } catch (EncodeException e) { logger.error(e.toString()); } }
public void send(String receiverid, String message) { if (receiverid == null || receiverid.isEmpty()) { logger.info("Send: {}", "not receiver"); return; } try { session.getBasicRemote().sendObject(new Message(clientid, receiverid, message)); logger.info("Send: {}", message); } catch (IOException e) { logger.error(e.toString()); } catch (EncodeException e) { logger.error(e.toString()); } }
public void sendMessage(PlatformManagementKnowledgeBean bean) throws IOException, EncodeException { this.peerLoggerServer.getBasicRemote().sendObject(bean); }
@Test public void testBroadcastWithEncodeException() throws Exception { final RemoteEndpoint.Basic endpoint = mock(RemoteEndpoint.Basic.class); doThrow(new EncodeException(null, "encode error")).when(endpoint).sendObject(any()); when(session.getBasicRemote()).thenReturn(endpoint); when(session.isOpen()).thenReturn(true); manager.addSession(session); final KieServerControllerNotification notification = new KieServerControllerNotification(); manager.broadcastObject(notification); verify(endpoint, timeout(TIMEOUT)).sendObject(notification); } }
@OnOpen public void open(Session session) { try { session.getBasicRemote().sendObject(new Message("Welcome")); } catch (IOException e) { logger.error(e.toString()); } catch (EncodeException e) { logger.error(e.toString()); } logger.info("Connection opened.login time {}", new Date()); }
@Test public void testServerTemplateDeleted() throws Exception { final ServerTemplateDeleted event = new ServerTemplateDeleted("serverTemplateId"); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Test public void testServerInstanceDeleted() throws Exception { final ServerInstanceDeleted event = new ServerInstanceDeleted("serverId"); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Test public void testBroadcast() throws Exception { final RemoteEndpoint.Basic endpoint = mock(RemoteEndpoint.Basic.class); when(session.getBasicRemote()).thenReturn(endpoint); when(session.isOpen()).thenReturn(true); manager.addSession(session); final KieServerControllerNotification notification = new KieServerControllerNotification(); manager.broadcastObject(notification); verify(endpoint, timeout(TIMEOUT)).sendObject(notification); }
@Override public void onMessage(Object message) { Object result = callMethod(method, extractors, session, true, message); if (result != null) { try { session.getBasicRemote().sendObject(result); } catch (Exception e) { onError(session, e); } } }
@Override public void onMessage(Object partialMessage, boolean last) { Object result = callMethod(method, extractors, session, true, partialMessage, last); if (result != null) { try { session.getBasicRemote().sendObject(result); } catch (Exception e) { onError(session, e); } } }
public void sendAll(String message) { try { session.getBasicRemote().sendObject(new Message(clientid, "all", message)); logger.info("Send: {}", message); } catch (IOException e) { logger.error(e.toString()); } catch (EncodeException e) { logger.error(e.toString()); } }
@Test public void testServerInstanceUpdated() throws Exception { final ServerInstanceUpdated event = new ServerInstanceUpdated(new ServerInstance()); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Test public void testServerInstanceConnected() throws Exception { final ServerInstanceConnected event = new ServerInstanceConnected(new ServerInstance()); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Override public void onMessage(Object partialMessage, boolean last) { Object result = callMethod(method, extractors, session, true, partialMessage, last); if (result != null) { try { session.getBasicRemote().sendObject(result); } catch (Exception e) { onError(session, e); } } }
@OnError public void onError(Session session, Throwable t) throws IOException, EncodeException { log.error("Caught exception while handling request for session " + session.getId(), t); if (t instanceof MatlabException) { session.getBasicRemote().sendObject(t); } else { session.getBasicRemote() .sendObject(new MatlabException("Could not execute request", t)); } }
@Test public void testServerInstanceDisconnected() throws Exception { final ServerInstanceDisconnected event = new ServerInstanceDisconnected("serverId"); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
@Override public void onMessage(Object message) { Object result = callMethod(method, extractors, session, true, message); if (result != null) { try { session.getBasicRemote().sendObject(result); } catch (Exception e) { onError(session, e); } } }
@Test public void testServerTemplateUpdated() throws Exception { final ServerTemplateUpdated event = new ServerTemplateUpdated(new ServerTemplate()); notificationService.notify(event); verify(endpoint, timeout(TIMEOUT)).sendObject(new KieServerControllerNotification(event)); }
/** * Send a execution request message. */ public void sendMessage( ExecutionRequest request ) throws KettleException { sessionValid(); try { request.setReuseSparkContext( reuseSparkContext ); this.userSession.getBasicRemote().sendObject( request ); } catch ( Exception e ) { throw new KettleException( e ); } }