Java Examples for javax.websocket.OnMessage

The following java examples will help you to understand the usage of javax.websocket.OnMessage. These source code samples are taken from different open source projects.

Example 1
Project: IronBrain-master  File: IBServerEndpoint.java View source code
@OnMessage
public void onMessage(String message, Session session) {
    try {
        OutputStream sendStream = session.getBasicRemote().getSendStream();
        switch(message) {
            case "screenshot":
                CountDownLatch latch = new CountDownLatch(1);
                ScreenCapture screenCapture = new ScreenCapture( img -> {
                    image = img;
                    latch.countDown();
                });
                screenCapture.setVisible(true);
                latch.await();
                ImageWriter writer = ImageIO.getImageWritersByFormatName(Main.SCREEN_SHOT_FILE_FORMAT).next();
                ImageWriteParam imgParam = writer.getDefaultWriteParam();
                imgParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
                //Highest quality
                imgParam.setCompressionQuality(1.0F);
                ImageOutputStream ios = ImageIO.createImageOutputStream(sendStream);
                writer.setOutput(ios);
                IIOImage iioImage = new IIOImage(image, null, null);
                writer.write(null, iioImage, imgParam);
                sendStream.close();
                break;
        }
    } catch (IOExceptionInterruptedException |  e1) {
        e1.printStackTrace();
    }
}
Example 2
Project: edit-2015-master  File: BrickClient.java View source code
@OnMessage
public void onMessage(String json, Session session) throws IOException {
    this.session = session;
    try {
        final JsonObject jsonCommand = Json.createReader(new StringReader(json)).readObject();
        System.out.println("Parsed: " + jsonCommand.toString());
        final String command = jsonCommand.getString("command");
        if (command.isEmpty())
            Log.info("No command given.");
        else if (command.equals("get")) {
            final String data = jsonCommand.getString("data");
            Order order = ParseCommand(data);
            order.getItem = 1;
            InformServer("start");
            // go fetch the item
            find_path(order.x, order.y, order.side != 0 ? true : false, order.getItem != 0 ? true : false);
        } else if (command.equals("put")) {
            final String data = jsonCommand.getString("data");
            Order order = ParseCommand(data);
            order.getItem = 0;
            InformServer("start");
            // go place the item
            find_path(order.x, order.y, order.side != 0 ? true : false, order.getItem != 0 ? true : false);
        } else if (command.equals("terminate")) {
            Log.info("Press escape to exit.");
            if (Button.waitForAnyPress() == Button.ID_ESCAPE) {
                System.exit(0);
            }
        } else {
            Log.info("Command " + command + " doesn't exist.");
        }
    } catch (JsonException je) {
        System.out.print(json);
    }
}
Example 3
Project: jetty.project-master  File: ConfiguratorTest.java View source code
@OnMessage
public String echo(Session session, String message) {
    List<Extension> negotiatedExtensions = session.getNegotiatedExtensions();
    if (negotiatedExtensions == null) {
        return "negotiatedExtensions=null";
    } else {
        return "negotiatedExtensions=" + negotiatedExtensions.stream().map(( ext) -> ext.getName()).collect(Collectors.joining(",", "[", "]"));
    }
}
Example 4
Project: org.ops4j.pax.web-master  File: ChatEndpoint.java View source code
@OnMessage
public void onMessage(final Session session, final ChatMessage chatMessage) {
    String room = (String) session.getUserProperties().get("room");
    try {
        for (Session s : session.getOpenSessions()) {
            if (s.isOpen() && room.equals(s.getUserProperties().get("room"))) {
                s.getBasicRemote().sendObject(chatMessage);
            }
        }
    } catch (IOExceptionEncodeException |  e) {
        log.warn("onMessage failed", e);
    }
}
Example 5
Project: aerogear-simplepush-java-client-master  File: EchoEndpoint.java View source code
@OnMessage
public void receiveTextMessage(String message, Session session) throws IOException {
    String request = message;
    final MessageType messageType = JsonUtil.parseFrame(request);
    switch(messageType.getMessageType()) {
        case HELLO:
            session.getBasicRemote().sendText(JsonUtil.toJson(new HelloResponseImpl(UUIDUtil.newUAID())));
            break;
        case REGISTER:
            final RegisterMessageImpl registerMessage = JsonUtil.fromJson(request, RegisterMessageImpl.class);
            final StatusImpl status = new StatusImpl(200, "N/A");
            final String channelId = registerMessage.getChannelId();
            final RegisterResponseImpl response = new RegisterResponseImpl(channelId, status, "ws://localhost:" + 9999);
            session.getBasicRemote().sendText(JsonUtil.toJson(response));
            break;
        case UNREGISTER:
            break;
        /**
             * Convenient manner of sending Notification to the client, that will not happen in a real SPS server
             */
        case NOTIFICATION:
            session.getBasicRemote().sendText(JsonUtil.toJson(new NotificationMessageImpl(new AckImpl(UUIDUtil.newUAID(), 1))));
    }
}
Example 6
Project: Greencode-Framework-master  File: WebSocket.java View source code
@OnMessage
public void onMessage(String message, Session session) throws IOException, ServletException {
    final WebSocketData wsData = new Gson().fromJson(message, WebSocketData.class);
    wsData.httpSession = this.session;
    wsData.session = session;
    wsData.headers = (MimeHeaders) session.getUserProperties().get("headers");
    wsData.localPort = (Integer) session.getUserProperties().get("localPort");
    wsData.remoteHost = (String) session.getUserProperties().get("remoteHost");
    wsData.remoteAddr = (String) session.getUserProperties().get("remoteAddr");
    wsData.requestURI = wsData.url;
    wsData.requestURL = new StringBuffer("http://").append(wsData.remoteHost).append(":").append(wsData.localPort).append("/").append(wsData.url);
    try {
        final String servletPath = wsData.url.indexOf(Core.CONTEXT_PATH) == 0 ? wsData.url.substring(Core.CONTEXT_PATH.length() + 1) : wsData.url;
        if (servletPath.equals("$synchronize")) {
            DOMScanner.synchronize(servletPath, request, response, wsData);
        } else {
            new Thread(new Runnable() {

                public void run() {
                    try {
                        Core.coreInit(servletPath, request, response, null, wsData);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            }).start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 7
Project: Hydrograph-master  File: HydrographUiClientSocket.java View source code
/**
	 * 
	 * Called by web socket server, message contain execution tracking status that updated on job canvas.
	 *
	 * @param message the message
	 * @param session the session
	 */
@OnMessage
public void updateJobTrackingStatus(String message, Session session) {
    final String status = message;
    Display.getDefault().asyncExec(new Runnable() {

        public void run() {
            Gson gson = new Gson();
            ExecutionStatus executionStatus = gson.fromJson(status, ExecutionStatus.class);
            IWorkbenchPage page = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage();
            IEditorReference[] refs = page.getEditorReferences();
            for (IEditorReference ref : refs) {
                IEditorPart editor = ref.getEditor(false);
                if (editor instanceof ELTGraphicalEditor) {
                    ELTGraphicalEditor editPart = (ELTGraphicalEditor) editor;
                    if (editPart.getJobId().equals(executionStatus.getJobId()) || (((editPart.getContainer() != null) && (editPart.getContainer().getUniqueJobId().equals(executionStatus.getJobId()))) && editPart.getContainer().isOpenedForTracking())) {
                        TrackingStatusUpdateUtils.INSTANCE.updateEditorWithCompStatus(executionStatus, (ELTGraphicalEditor) editor, false);
                    }
                }
            }
        }
    });
}
Example 8
Project: javaee7-developer-handbook-master  File: ChatServerEndPoint.java View source code
@OnMessage
public void receiveMessage(String message, Session session) {
    System.out.printf("%s.receiveMessage() called with message=`%s', session %s, thread [%s]\n", getClass().getSimpleName(), message, session, Thread.currentThread().getName());
    String tokens[] = message.split(DELIMITER);
    String command = tokens[0];
    String username = (tokens.length > 1 ? tokens[1] : "");
    String text = (tokens.length > 2 ? tokens[2] : "");
    ChatUser user = new ChatUser(session, username);
    if (LOGIN_REQUEST.equals(command)) {
        chatRoom.addChatUser(user);
    } else if (LOGOUT_REQUEST.equals(command)) {
        chatRoom.removeChatUser(user);
    } else if (SEND_MSG_REQUEST.equals(command)) {
        chatRoom.broadcastMessage(username, text);
    } else {
        encodeErrorReply(session, username, String.format("unknown command: %s", command));
    }
}
Example 9
Project: javaee7-samples-master  File: MyEndpoint.java View source code
@OnMessage
public String echoText(String name, Session session) {
    Map<String, Object> map = session.getUserProperties();
    Integer count = 0;
    if (map.get("count") != null) {
        count = (Integer) map.get("count");
    }
    System.out.format("Called %d times", ++count);
    map.put("count", count);
    return name + String.valueOf(count);
}
Example 10
Project: jReto-master  File: DiscoveryEndpoint.java View source code
@OnMessage
public void binaryMessage(byte[] data, Session session) throws IOException {
    RemoteP2PPacket packet = RemoteP2PPacket.packetFromData(data);
    if (packet == null) {
        LOGGER.log(Level.WARNING, "Discovery connection received invalid data.");
        return;
    }
    switch(packet.type) {
        case RemoteP2PPacket.START_ADVERTISEMENT:
            ConnectionManager.getInstance().startAdvertisingPeer(packet.uuid, session);
            break;
        case RemoteP2PPacket.STOP_ADVERTISEMENT:
            ConnectionManager.getInstance().stopAdvertisingPeer(packet.uuid, session);
            break;
        case RemoteP2PPacket.START_BROWSING:
            ConnectionManager.getInstance().startSendingDiscoveryUpdates(session);
            break;
        case RemoteP2PPacket.STOP_BROWSING:
            ConnectionManager.getInstance().stopSendingDiscoveryUpdates(session);
            break;
        default:
            LOGGER.log(Level.WARNING, "Discovery connection received invalid packet. You may only send START_ADVERTISEMENT and STOP_ADVERTISEMENT packets to the server.");
    }
}
Example 11
Project: Tomcat-master  File: TestClose.java View source code
@OnMessage
public void onMessage(Session session, String message) {
    log.info("Message received: " + message);
    events.onMessageCalled.countDown();
    awaitLatch(events.onMessageWait, "onMessageWait not triggered");
    if (events.onMessageSends) {
        try {
            int count = 0;
            // triggers an error here.
            while (count < 10) {
                count++;
                session.getBasicRemote().sendText("Test reply");
                Thread.sleep(500);
            }
        } catch (IOExceptionInterruptedException |  e) {
        }
    }
}
Example 12
Project: feathercon-master  File: WebSocketEndpointConfiguration.java View source code
// file bug:  Option-return at EOL should offer to Iterate, like it does for Colelctions
private void requireHandlerMethods(Class endpointClass) {
    boolean hasOnOpenAnnotation = false;
    boolean hasOnMessageAnnotation = false;
    boolean hasOnCloseAnnotation = false;
    boolean hasOnErrorAnnotation = false;
    Method[] methods = endpointClass.getMethods();
    for (Method method : methods) {
        Annotation[] annotations = method.getAnnotations();
        for (Annotation annotation : annotations) {
            if (annotation instanceof OnOpen) {
                hasOnOpenAnnotation = true;
                continue;
            }
            if (annotation instanceof OnClose) {
                hasOnCloseAnnotation = true;
                continue;
            }
            if (annotation instanceof OnMessage) {
                hasOnMessageAnnotation = true;
                continue;
            }
            if (annotation instanceof OnError) {
                hasOnErrorAnnotation = true;
                continue;
            }
        }
    }
    if (!(hasOnOpenAnnotation && hasOnMessageAnnotation && hasOnCloseAnnotation && hasOnErrorAnnotation)) {
        throw new IllegalArgumentException(String.format("Class %s must have methods annotated with OnOpen, OnClose, OnMessage, and OnError javax.websocket annotations", endpointClass));
    }
}
Example 13
Project: javaee7-jms-websocket-example-master  File: WebSocketEndpoint.java View source code
@OnMessage
public void onMessage(final String message, final Session client) {
    try {
        client.getBasicRemote().sendText("sending message to SessionBean...");
    } catch (IOException ex) {
        Logger.getLogger(WebSocketEndpoint.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (senderBean != null) {
        senderBean.sendMessage(message);
    }
}
Example 14
Project: JavaIncrementalParser-master  File: MyEndpoint.java View source code
@OnMessage
public String echoText(String name, Session session) {
    Map<String, Object> map = session.getUserProperties();
    Integer count = 0;
    if (map.get("count") != null) {
        count = (Integer) map.get("count");
    }
    System.out.format("Called %d times", ++count);
    map.put("count", count);
    return name + String.valueOf(count);
}
Example 15
Project: moonshine-master  File: HandlerDispatcher.java View source code
private void registerOnMessageMethod(Method method, Provider<?> provider) {
    Class<?>[] parameterTypes = method.getParameterTypes();
    if (parameterTypes.length != 1) {
        throw new RuntimeException("Method marked with @" + OnMessage.class.getSimpleName() + " must have exactly one argument whose super class is " + JsonMessage.class.getSimpleName());
    }
    Class<?> parameterType = parameterTypes[0];
    if (!JsonMessage.class.isAssignableFrom(parameterType)) {
        throw new RuntimeException("Method marked with @" + OnMessage.class.getSimpleName() + " must have exactly one argument whose super class is " + JsonMessage.class.getSimpleName());
    }
    decoderObjectMapper.registerSubtypes(parameterType);
    Class<?> returnType = method.getReturnType();
    if (returnType != Void.TYPE) {
        encoderObjectMapper.registerSubtypes(returnType);
    }
    onMessageMethods.add(new OnMessageMethodMetadata(parameterType, provider, method));
}
Example 16
Project: quickstart-master  File: BidWebSocketEndpoint.java View source code
// This method receives a Message that contains a command
// The Message object is "decoded" by the MessageDecoder class
@OnMessage
public void onMessage(Session session, Message message) throws IOException, EncodeException {
    if (message.getCommand().equals("newBid")) {
        Bidding bidding = BiddingFactory.getBidding();
        bidding.addBid(new Bid(session.getId(), message.getBidValue()));
    }
    if (message.getCommand().equals("buyItNow")) {
        Bidding bidding = BiddingFactory.getBidding();
        bidding.buyItNow();
    }
    if (message.getCommand().equals("resetBid")) {
        BiddingFactory.resetBidding();
    }
    notifyAllSessions(BiddingFactory.getBidding());
}
Example 17
Project: siebog-master  File: WebClientSocket.java View source code
@OnMessage
public void onMessage(String message, Session session) {
    if (message == null || message.isEmpty())
        throw new IllegalArgumentException("Messages cannot be empty.");
    char cmd = message.charAt(0);
    String content = message.substring(1);
    switch(cmd) {
        case MSG_REGISTER:
            doRegister(content, session);
            break;
        case MSG_DEREGISTER:
            doUnregister(content, session);
            break;
        case MSG_GET_STATE:
            doGetState(content, session);
            break;
        case MSG_STORE_STATE:
            doStoreState(content);
            break;
    }
}
Example 18
Project: tomcat70-master  File: TestClose.java View source code
@OnMessage
public void onMessage(Session session, String message) {
    log.info("Message received: " + message);
    events.onMessageCalled.countDown();
    awaitLatch(events.onMessageWait, "onMessageWait not triggered");
    if (events.onMessageSends) {
        try {
            int count = 0;
            // triggers an error here.
            while (count < 10) {
                count++;
                session.getBasicRemote().sendText("Test reply");
                Thread.sleep(500);
            }
        } catch (IOException e) {
        } catch (InterruptedException e) {
        }
    }
}
Example 19
Project: tomee-master  File: LiveReloadEndpoint.java View source code
@OnMessage
public void onMessage(final String msg, final Session session) {
    final Command command = mapper.readObject(msg, Command.class);
    if (command.isHello()) {
        try {
            session.getBasicRemote().sendText(mapper.writeObjectAsString(HELLO));
        } catch (final IOException e) {
            throw new IllegalStateException(e);
        }
        this.watcher.addSession(session);
        logger.info("Registered livereload session #" + session.getId());
    } else if (command.isClientUpdate()) {
        logger.info("Ignoring livereload client update message: " + msg);
    } else if (command.isInfo()) {
        if (!loggedInfo) {
            logger.info("Livereload registration:\n  - url:" + command.getUrl() + "\n  - plugins: " + command.getPlugins());
            loggedInfo = true;
        }
    } else {
        logger.info("Unknown livereload message: " + msg);
    }
}
Example 20
Project: tyrus-master  File: MessageHandlersTest.java View source code
@OnMessage
public void onMessage(Session session, byte[] message, boolean isLast) {
    buffer.add(message);
    if (isLast) {
        try {
            ByteBuffer b = null;
            for (byte[] bytes : buffer) {
                if (b == null) {
                    b = ByteBuffer.wrap(bytes);
                } else {
                    b = joinBuffers(b, ByteBuffer.wrap(bytes));
                }
            }
            session.getBasicRemote().sendBinary(b);
        } catch (IOException e) {
        }
        buffer.clear();
    }
}
Example 21
Project: websocket-message-handlers-example-master  File: FileUpload.java View source code
@OnMessage
public void processBinaryStream(InputStream is) {
    int count = 0;
    byte[] buff = new byte[1024];
    try {
        while (is.available() > 0) {
            count = +is.read(buff);
            ByteBuffer buffer = ByteBuffer.wrap(buff, 0, count);
            int res = channel.write(buffer, length);
            this.length += res;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (length == size) {
        try {
            channel.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        channel = null;
    }
}
Example 22
Project: aerogear-sync-server-master  File: SyncEndpoint.java View source code
@OnMessage
public String onMessage(String message, Session webSocketSession) {
    final JsonNode json = JsonMapper.asJsonNode(message);
    switch(MessageType.from(json.get("msgType").asText())) {
        case ADD:
            final Document<JsonNode> doc = syncEngine.documentFromJson(json);
            final String clientId = json.get("clientId").asText();
            final PatchMessage<JsonPatchEdit> patchMessage = addSubscriber(doc, clientId, webSocketSession);
            webSocketSession.getUserProperties().put(DOC_ADD, true);
            return (patchMessage.asJson());
        case PATCH:
            final PatchMessage<JsonPatchEdit> clientPatchMessage = syncEngine.patchMessageFromJson(json.toString());
            checkForReconnect(clientPatchMessage.documentId(), clientPatchMessage.clientId(), webSocketSession);
            patch(clientPatchMessage);
            break;
        case DETACH:
            // detach the client from a specific document.
            break;
        case UNKNOWN:
            return "{\"result\": \"Unknown msgType '" + json.get("msgType").asText() + "'\"}";
    }
    return message;
}
Example 23
Project: angular-jsf-master  File: ChatServer.java View source code
@OnMessage
public void onMessage(@Valid ChatMessage message, Session session) {
    logger.log(Level.INFO, "Received message {0} from peer {1}", new Object[] { message, session });
    for (Session peer : peers) {
        try {
            logger.log(Level.INFO, "Broadcasting message {0} to peer {1}", new Object[] { message, peer });
            peer.getBasicRemote().sendObject(message);
        } catch (IOExceptionEncodeException |  ex) {
            logger.log(Level.SEVERE, "Error sending message", ex);
        }
    }
}
Example 24
Project: diirt-master  File: WSEndpoint.java View source code
@OnMessage
public void onMessage(Session session, Message message) {
    switch(message.getMessage()) {
        case SUBSCRIBE:
            onSubscribe(session, (MessageSubscribe) message);
            return;
        case UNSUBSCRIBE:
            onUnsubscribe(session, (MessageUnsubscribe) message);
            return;
        case PAUSE:
            onPause(session, (MessagePause) message);
            return;
        case RESUME:
            onResume(session, (MessageResume) message);
            return;
        case WRITE:
            onWrite(session, (MessageWrite) message);
            return;
        default:
            sendError(session, message.getId(), "Message '" + message.getMessage() + "' not supported on this server");
    }
}
Example 25
Project: diqube-master  File: WebSocketEndpoint.java View source code
@OnMessage
public void onMessage(String msg, Session session) throws Exception {
    try {
        logger.trace("Received message on session {}: {}", session, msg);
        for (WebSocketEndpointListener listener : getBeanCtx(session).getBeansOfType(WebSocketEndpointListener.class).values()) {
            listener.socketMessage();
        }
        JsonRequestDeserializer deserializer = getBeanCtx(session).getBean(JsonRequestDeserializer.class);
        JsonRequestRegistry requestRegistry = getBeanCtx(session).getBean(JsonRequestRegistry.class);
        JsonRequest request = deserializer.deserialize(msg, session);
        requestRegistry.registerRequest(session, request);
        request.executeCommand();
    } catch (Exception e) {
        logger.error("Exception on session {}. Swallowing.", session, e);
    }
}
Example 26
Project: etsn05-master  File: SnakeAnnotation.java View source code
@OnMessage
public void onTextMessage(String message) {
    if ("west".equals(message)) {
        snake.setDirection(Direction.WEST);
    } else if ("north".equals(message)) {
        snake.setDirection(Direction.NORTH);
    } else if ("east".equals(message)) {
        snake.setDirection(Direction.EAST);
    } else if ("south".equals(message)) {
        snake.setDirection(Direction.SOUTH);
    }
}
Example 27
Project: javaee-javascript-master  File: ChatServer.java View source code
@OnMessage
public void onMessage(@Valid ChatMessage message, Session session) {
    logger.log(Level.INFO, "Received message {0} from peer {1}", new Object[] { message, session });
    for (Session peer : peers) {
        try {
            logger.log(Level.INFO, "Broadcasting message {0} to peer {1}", new Object[] { message, peer });
            peer.getBasicRemote().sendObject(message);
        } catch (IOExceptionEncodeException |  ex) {
            logger.log(Level.SEVERE, "Error sending message", ex);
        }
    }
}
Example 28
Project: javaee7-websocket-master  File: MatchEndpoint.java View source code
@OnMessage
public void message(final Session session, BetMessage msg, @PathParam("match-id") String matchId) {
    logger.log(Level.INFO, "Received: Bet Match Winner - {0}", msg.getWinner());
    //check if the user had already bet and save this bet
    boolean hasAlreadyBet = session.getUserProperties().containsKey("bet");
    session.getUserProperties().put("bet", msg.getWinner());
    //Send betMsg with bet count
    if (!nbBetsByMatch.containsKey(matchId)) {
        nbBetsByMatch.put(matchId, new AtomicInteger());
    }
    if (!hasAlreadyBet) {
        nbBetsByMatch.get(matchId).incrementAndGet();
    }
    sendBetMessages(null, matchId, false);
}
Example 29
Project: ldrbrd-master  File: SnakeAnnotation.java View source code
@OnMessage
public void onTextMessage(String message) {
    if ("west".equals(message)) {
        snake.setDirection(Direction.WEST);
    } else if ("north".equals(message)) {
        snake.setDirection(Direction.NORTH);
    } else if ("east".equals(message)) {
        snake.setDirection(Direction.EAST);
    } else if ("south".equals(message)) {
        snake.setDirection(Direction.SOUTH);
    }
}
Example 30
Project: undertow-master  File: AnnotatedEndpointFactory.java View source code
public static AnnotatedEndpointFactory create(final Class<?> endpointClass, final EncodingFactory encodingFactory, final Set<String> paths) throws DeploymentException {
    final Set<Class<? extends Annotation>> found = new HashSet<>();
    BoundMethod onOpen = null;
    BoundMethod onClose = null;
    BoundMethod onError = null;
    BoundMethod textMessage = null;
    BoundMethod binaryMessage = null;
    BoundMethod pongMessage = null;
    Class<?> c = endpointClass;
    do {
        for (final Method method : c.getDeclaredMethods()) {
            if (method.isAnnotationPresent(OnOpen.class)) {
                if (found.contains(OnOpen.class)) {
                    if (!onOpen.overrides(method)) {
                        throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnOpen.class);
                    } else {
                        continue;
                    }
                }
                found.add(OnOpen.class);
                onOpen = new BoundMethod(method, null, false, 0, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, EndpointConfig.class, true), createBoundPathParameters(method, paths, endpointClass));
            }
            if (method.isAnnotationPresent(OnClose.class)) {
                if (found.contains(OnClose.class)) {
                    if (!onClose.overrides(method)) {
                        throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnClose.class);
                    } else {
                        continue;
                    }
                }
                found.add(OnClose.class);
                onClose = new BoundMethod(method, null, false, 0, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, CloseReason.class, true), createBoundPathParameters(method, paths, endpointClass));
            }
            if (method.isAnnotationPresent(OnError.class)) {
                if (found.contains(OnError.class)) {
                    if (!onError.overrides(method)) {
                        throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnError.class);
                    } else {
                        continue;
                    }
                }
                found.add(OnError.class);
                onError = new BoundMethod(method, null, false, 0, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, Throwable.class, false), createBoundPathParameters(method, paths, endpointClass));
            }
            if (method.isAnnotationPresent(OnMessage.class) && !method.isBridge()) {
                if (binaryMessage != null && binaryMessage.overrides(method)) {
                    continue;
                }
                if (textMessage != null && textMessage.overrides(method)) {
                    continue;
                }
                if (pongMessage != null && pongMessage.overrides(method)) {
                    continue;
                }
                long maxMessageSize = method.getAnnotation(OnMessage.class).maxMessageSize();
                boolean messageHandled = false;
                //this is a bit more complex
                Class<?>[] parameterTypes = method.getParameterTypes();
                int booleanLocation = -1;
                for (int i = 0; i < parameterTypes.length; ++i) {
                    if (hasAnnotation(PathParam.class, method.getParameterAnnotations()[i])) {
                        continue;
                    }
                    final Class<?> param = parameterTypes[i];
                    if (param == boolean.class || param == Boolean.class) {
                        booleanLocation = i;
                    } else if (encodingFactory.canDecodeText(param)) {
                        if (textMessage != null) {
                            throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                        }
                        textMessage = new BoundMethod(method, param, true, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, boolean.class, true), new BoundSingleParameter(i, param), createBoundPathParameters(method, paths, endpointClass));
                        messageHandled = true;
                        break;
                    } else if (encodingFactory.canDecodeBinary(param)) {
                        if (binaryMessage != null) {
                            throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                        }
                        binaryMessage = new BoundMethod(method, param, true, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, boolean.class, true), new BoundSingleParameter(i, param), createBoundPathParameters(method, paths, endpointClass));
                        messageHandled = true;
                        break;
                    } else if (param.equals(byte[].class)) {
                        if (binaryMessage != null) {
                            throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                        }
                        binaryMessage = new BoundMethod(method, byte[].class, false, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, boolean.class, true), new BoundSingleParameter(i, byte[].class), createBoundPathParameters(method, paths, endpointClass));
                        messageHandled = true;
                        break;
                    } else if (param.equals(ByteBuffer.class)) {
                        if (binaryMessage != null) {
                            throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                        }
                        binaryMessage = new BoundMethod(method, ByteBuffer.class, false, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, boolean.class, true), new BoundSingleParameter(i, ByteBuffer.class), createBoundPathParameters(method, paths, endpointClass));
                        messageHandled = true;
                        break;
                    } else if (param.equals(InputStream.class)) {
                        if (binaryMessage != null) {
                            throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                        }
                        binaryMessage = new BoundMethod(method, InputStream.class, false, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, boolean.class, true), new BoundSingleParameter(i, InputStream.class), createBoundPathParameters(method, paths, endpointClass));
                        messageHandled = true;
                        break;
                    } else if (param.equals(String.class) && getPathParam(method, i) == null) {
                        if (textMessage != null) {
                            throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                        }
                        textMessage = new BoundMethod(method, String.class, false, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, boolean.class, true), new BoundSingleParameter(i, String.class), createBoundPathParameters(method, paths, endpointClass));
                        messageHandled = true;
                        break;
                    } else if (param.equals(Reader.class) && getPathParam(method, i) == null) {
                        if (textMessage != null) {
                            throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                        }
                        textMessage = new BoundMethod(method, Reader.class, false, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, boolean.class, true), new BoundSingleParameter(i, Reader.class), createBoundPathParameters(method, paths, endpointClass));
                        messageHandled = true;
                        break;
                    } else if (param.equals(PongMessage.class)) {
                        if (pongMessage != null) {
                            throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                        }
                        pongMessage = new BoundMethod(method, PongMessage.class, false, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(i, PongMessage.class), createBoundPathParameters(method, paths, endpointClass));
                        messageHandled = true;
                        break;
                    }
                }
                if (!messageHandled && booleanLocation != -1) {
                    //so it turns out that the boolean was the message type and not a final fragement indicator
                    if (textMessage != null) {
                        throw JsrWebSocketMessages.MESSAGES.moreThanOneAnnotation(OnMessage.class);
                    }
                    Class<?> boolClass = parameterTypes[booleanLocation];
                    textMessage = new BoundMethod(method, boolClass, true, maxMessageSize, new BoundSingleParameter(method, Session.class, true), new BoundSingleParameter(method, boolean.class, true), new BoundSingleParameter(booleanLocation, boolClass), createBoundPathParameters(method, paths, endpointClass));
                    messageHandled = true;
                }
                if (!messageHandled) {
                    throw JsrWebSocketMessages.MESSAGES.couldNotFindMessageParameter(method);
                }
            }
        }
        c = c.getSuperclass();
    } while (c != Object.class && c != null);
    return new AnnotatedEndpointFactory(endpointClass, onOpen, onClose, onError, textMessage, binaryMessage, pongMessage);
}
Example 31
Project: crash-master  File: CRaSHConnector.java View source code
@OnMessage
public void incoming(String message, Session wsSession) {
    String key = wsSession.getId();
    log.fine("Received message " + message + " from session " + key);
    current.set(wsSession);
    try {
        CRaSHSession session = sessions.get(key);
        if (session != null) {
            JsonParser parser = new JsonParser();
            JsonElement json = parser.parse(message);
            if (json instanceof JsonObject) {
                JsonObject event = (JsonObject) json;
                JsonElement type = event.get("type");
                if (type.getAsString().equals("welcome")) {
                    log.fine("Sending welcome + prompt");
                    session.send("print", session.shell.getWelcome());
                    session.send("prompt", session.shell.getPrompt());
                } else if (type.getAsString().equals("execute")) {
                    String command = event.get("command").getAsString();
                    int width = event.get("width").getAsInt();
                    int height = event.get("height").getAsInt();
                    ShellProcess process = session.shell.createProcess(command);
                    WSProcessContext context = new WSProcessContext(session, process, command, width, height);
                    if (session.current.getAndSet(context) == null) {
                        log.fine("Executing \"" + command + "\"");
                        process.execute(context);
                    } else {
                        log.fine("Could not execute \"" + command + "\"");
                    }
                } else if (type.getAsString().equals("cancel")) {
                    WSProcessContext current = session.current.getAndSet(null);
                    if (current != null) {
                        log.fine("Cancelling command \"" + current.command + "\"");
                        current.process.cancel();
                    } else {
                        log.fine("No process to cancel");
                    }
                } else if (type.getAsString().equals("key")) {
                    WSProcessContext current = session.current.get();
                    if (current != null) {
                        String _keyType = event.get("keyType").getAsString();
                        KeyType keyType = KeyType.valueOf(_keyType.toUpperCase());
                        if (keyType == KeyType.CHARACTER) {
                            int code = event.get("keyCode").getAsInt();
                            if (code >= 32) {
                                current.handle(KeyType.CHARACTER, new int[] { code });
                            }
                        } else {
                            current.handle(keyType, new int[0]);
                        }
                    } else {
                        log.fine("No process can handle the key event");
                    }
                } else if (type.getAsString().equals("complete")) {
                    String prefix = event.get("prefix").getAsString();
                    CompletionMatch completion = session.shell.complete(prefix);
                    Completion completions = completion.getValue();
                    Delimiter delimiter = completion.getDelimiter();
                    StringBuilder sb = new StringBuilder();
                    List<String> values = new ArrayList<String>();
                    try {
                        if (completions.getSize() == 1) {
                            String value = completions.getValues().iterator().next();
                            delimiter.escape(value, sb);
                            if (completions.get(value)) {
                                sb.append(delimiter.getValue());
                            }
                            values.add(sb.toString());
                        } else {
                            String commonCompletion = Utils.findLongestCommonPrefix(completions.getValues());
                            if (commonCompletion.length() > 0) {
                                delimiter.escape(commonCompletion, sb);
                                values.add(sb.toString());
                            } else {
                                for (Map.Entry<String, Boolean> entry : completions) {
                                    delimiter.escape(entry.getKey(), sb);
                                    values.add(sb.toString());
                                    sb.setLength(0);
                                }
                            }
                        }
                    } catch (IOException ignore) {
                    }
                    log.fine("Completing \"" + prefix + "\" with " + values);
                    session.send("complete", values);
                }
            }
        } else {
            log.fine("No shell session found");
        }
    } finally {
        current.set(null);
    }
}
Example 32
Project: guacamole-client-master  File: GuacamoleWebSocketTunnelEndpoint.java View source code
@OnMessage
public void onMessage(String message) {
    // Ignore inbound messages if there is no associated tunnel
    if (tunnel == null)
        return;
    GuacamoleWriter writer = tunnel.acquireWriter();
    try {
        // Write received message
        writer.write(message.toCharArray());
    } catch (GuacamoleConnectionClosedException e) {
        logger.debug("Connection to guacd closed.", e);
    } catch (GuacamoleException e) {
        logger.debug("WebSocket tunnel write failed.", e);
    }
    tunnel.releaseWriter();
}
Example 33
Project: muikku-master  File: CoOpsDocumentWebSocket.java View source code
@OnMessage
public void onMessage(Reader messageReader, Session client, @PathParam("HTMLMATERIALID") String fileId, @PathParam("SESSIONID") String sessionId) throws IOException {
    CoOpsSession session = coOpsSessionController.findSessionBySessionId(sessionId);
    if (session == null) {
        client.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "Not Found"));
        return;
    }
    if (!session.getHtmlMaterial().getId().equals(NumberUtils.createLong(fileId))) {
        client.close(new CloseReason(CloseReason.CloseCodes.VIOLATED_POLICY, "Session is associated with another fileId"));
        return;
    }
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        PatchMessage patchMessage;
        try {
            patchMessage = objectMapper.readValue(messageReader, PatchMessage.class);
        } catch (IOException e) {
            throw new CoOpsInternalErrorException(e);
        }
        if (patchMessage == null) {
            throw new CoOpsInternalErrorException("Could not parse message");
        }
        if (!patchMessage.getType().equals("patch")) {
            throw new CoOpsInternalErrorException("Unknown message type: " + patchMessage.getType());
        }
        Patch patch = patchMessage.getData();
        coOpsApi.filePatch(fileId, patch.getSessionId(), patch.getRevisionNumber(), patch.getPatch(), patch.getProperties(), patch.getExtensions());
    } catch (CoOpsInternalErrorException e) {
        client.close(new CloseReason(CloseReason.CloseCodes.UNEXPECTED_CONDITION, "Internal Error"));
    } catch (CoOpsUsageException e) {
        client.getAsyncRemote().sendText(objectMapper.writeValueAsString(new ErrorMessage("patchError", 400, e.getMessage())));
    } catch (CoOpsNotFoundException e) {
        client.getAsyncRemote().sendText(objectMapper.writeValueAsString(new ErrorMessage("patchError", 404, e.getMessage())));
    } catch (CoOpsConflictException e) {
        client.getAsyncRemote().sendText(objectMapper.writeValueAsString(new ErrorMessage("patchRejected", 409, "Conflict")));
    } catch (CoOpsForbiddenException e) {
        client.getAsyncRemote().sendText(objectMapper.writeValueAsString(new ErrorMessage("patchError", 500, e.getMessage())));
    }
}
Example 34
Project: rtgov-master  File: WSActiveCollectionServer.java View source code
/**
     * This method processes an inbound message on the websocket.
     * 
     * @param message The message
     * @param session The associated websocket session
     */
@OnMessage
public void onMessage(String message, Session session) {
    synchronized (_acmListeners) {
        if (!_acmListeners.containsKey(session.getId())) {
            LOG.severe("Websocket session not registered");
        } else {
            ACMListener l = _acmListeners.get(session.getId());
            try {
                ActiveCollectionCommand command = MAPPER.readValue(message.getBytes(), ActiveCollectionCommand.class);
                if (command.getRegister() != null) {
                    if (LOG.isLoggable(Level.FINEST)) {
                        LOG.finest("Register listener for notifications on active collection '" + command.getRegister().getCollection() + "'");
                    }
                    l.register(command.getRegister().getCollection());
                }
                if (command.getUnregister() != null) {
                    if (LOG.isLoggable(Level.FINEST)) {
                        LOG.finest("Unregister listener for notifications on active collection '" + command.getUnregister().getCollection() + "'");
                    }
                    l.register(command.getUnregister().getCollection());
                }
            } catch (Exception e) {
                LOG.log(Level.SEVERE, "Failed to deserialize the active collection command", e);
            }
        }
    }
}
Example 35
Project: spring-open-master  File: TopologyWebSocket.java View source code
/**
     * Received a text message.
     *
     * @param session the WebSocket session for the connection.
     * @param msg the received message.
     */
@OnMessage
public void onTextMessage(Session session, String msg) {
    log.debug("WebSocket Text message received: {}", msg);
// TODO: Sample code below for sending a response back
// NOTE: The transmission here must be synchronized by
// by the transmission by another thread within the run() method.
//
// String result = msg + " (from your server)";
// session.getBasicRemote().sendText(result);
//
// RemoteEndpoint.Basic basic = session.getBasicRemote();
// RemoteEndpoint.Async async = session.getAsyncRemote();
// session.getAsyncRemote().sendBinary(ByteBuffer data);
// session.getAsyncRemote().sendPing(ByteBuffer appData);
// session.getAsyncRemote().sendPong(ByteBuffer appData);
//
}
Example 36
Project: chatty-master  File: WebsocketClient.java View source code
@OnMessage
public synchronized void onMessage(String message, Session session) {
    System.out.println("RECEIVED: " + message);
    timeLastMessageReceived = System.currentTimeMillis();
    handler.handleReceived(message);
    receivedCount++;
    try {
        String[] split = message.split(" ", 3);
        int id = Integer.parseInt(split[0]);
        String command = split[1];
        String params = "";
        if (split.length == 3) {
            params = split[2];
        }
        handleCommand(id, command, params);
    } catch (ArrayIndexOutOfBoundsExceptionNumberFormatException |  ex) {
        LOGGER.warning("[FFZ-WS] Invalid message: " + message);
    }
}
Example 37
Project: platypus-master  File: JsServerModuleEndPoint.java View source code
@OnMessage
public void messageRecieved(Session websocketSession, String aData) throws Exception {
    PlatypusServerCore platypusCore = lookupPlaypusServerCore();
    in(platypusCore, websocketSession, (com.eas.server.Session aSession) -> {
        Logger.getLogger(JsServerModuleEndPoint.class.getName()).log(Level.FINE, "WebSocket container OnMessage {0}.", aSession.getId());
        JSObject messageEvent = Scripts.getSpace().makeObj();
        messageEvent.setMember("data", aData);
        messageEvent.setMember("id", websocketSession.getId());
        platypusCore.executeMethod(moduleName, WS_ON_MESSAGE, new Object[] { messageEvent }, true, (Object aResult) -> {
            Logger.getLogger(JsServerModuleEndPoint.class.getName()).log(Level.FINE, "{0} method of {1} module called successfully.", new Object[] { WS_ON_MESSAGE, moduleName });
        }, (Exception ex) -> {
            Logger.getLogger(JsServerModuleEndPoint.class.getName()).log(Level.SEVERE, null, ex);
        });
    });
}
Example 38
Project: OpenDolphin-master  File: PHRProxy.java View source code
@OnMessage
public void onMessage(String message) {
    getLogger().log(Level.INFO, "onMessage");
    JsonObject jso = getJsonObject(message);
    printJson(jso);
    // type
    // change, request, response, signal
    String type = jso.getString("type");
    JsonObject body = jso.getJsonObject("body");
    String timestamp = jso.getString("timestamp");
    int counter = jso.getInt("counter");
    if (!"change".equals(type)) {
        return;
    }
    if (!"create".equals(body.getString("operation"))) {
        // create, delete, update
        return;
    }
    if (!"Message".equals(body.getJsonObject("object").getString("type"))) {
        // Conversation, Message
        return;
    }
    JsonArray parts = body.getJsonObject("data").getJsonArray("parts");
    JsonObject part0 = parts.getJsonObject(0);
    if (!"text/plain".equals(part0.getString("mime_type"))) {
        return;
    }
    String sender = body.getJsonObject("data").getJsonObject("sender").getString("user_id");
    if (USER_ID.equals(sender)) {
        return;
    }
    // Conversatuin ID
    String conversation_uuid = body.getJsonObject("data").getJsonObject("conversation").getString("id");
    int index = conversation_uuid.lastIndexOf("/");
    if (index <= 0) {
        return;
    }
    conversation_uuid = conversation_uuid.substring(index + 1);
    String text = part0.getString("body");
    if (text.equals("処方") || text.equals("検査") || text.equals("ç—…å??") || text.equals("アレルギー")) {
        sendPHRRequest(conversation_uuid, sender, text);
    }
}
Example 39
Project: jbosstools-webservices-master  File: MyServer2Endpoint.java View source code
@OnMessage
public void onMessage(String string) {
}
Example 40
Project: overtown-master  File: Second.java View source code
@OnMessage
public void message(String message) {
}
Example 41
Project: callback-websocket-examples-master  File: WebsocketEndpoint.java View source code
@OnMessage
public void onWebSocketText(final Session session, String message) {
    marshaller.handleRequest(session, message);
}
Example 42
Project: URS-master  File: AnnotatedEndPointResource.java View source code
@OnMessage
public String sayHello(String message, Session session) {
    LOGGER.info("Received message from client: " + message);
    return message;
}
Example 43
Project: ursus-master  File: AnnotatedEndPointResource.java View source code
@OnMessage
public String sayHello(String message, Session session) {
    LOGGER.info("Received message from client: " + message);
    return message;
}
Example 44
Project: wildfly-master  File: AnnotatedEndpoint.java View source code
@OnMessage
public String message(String message, @PathParam("name") String name) {
    return message + " " + name;
}
Example 45
Project: comm-master  File: WebSocketTest.java View source code
@OnMessage
public void onMessage(String message, Session session) throws IOException, InterruptedException {
    System.out.println("接收客户端消�: " + message);
    session.getBasicRemote().sendText("�务器接收到你的消�:" + message);
}
Example 46
Project: hprose-java-master  File: WebSocketServer.java View source code
@OnMessage
public void onMessage(ByteBuffer buf, Session session) throws IOException {
    service.handle(buf, session);
}
Example 47
Project: jetty-web-sockets-jsr356-master  File: BroadcastClientEndpoint.java View source code
@OnMessage
public void onMessage(final Message message) {
    log.info(String.format("Received message '%s' from '%s'", message.getMessage(), message.getUsername()));
}
Example 48
Project: seed-master  File: ChatClientEndpoint1.java View source code
@OnMessage
public void processMessage(String message) {
    response = message;
    latch.countDown();
}
Example 49
Project: spring-boot-master  File: ReverseWebSocketEndpoint.java View source code
@OnMessage
public void handleMessage(Session session, String message) throws IOException {
    session.getBasicRemote().sendText("Reversed: " + new StringBuilder(message).reverse());
}
Example 50
Project: Teletask-api-master  File: JSONBroadcastingWebSocket.java View source code
@OnMessage
public void onMessage(Session session, String msg) {
}
Example 51
Project: californium.tools-master  File: ObserveSocket.java View source code
@OnMessage
public void onWebSocketText(String message) {
    System.out.println("Received TEXT message: " + message);
}
Example 52
Project: cyberattack-event-collector-master  File: WebsocketClientEndpoint.java View source code
/* (non-Javadoc)
	 * @see events.collect.SocketClientEndpoint#onMessage(java.lang.String)
	 */
@OnMessage
public void onMessage(String message) {
    if (this.messageHandler != null) {
        this.messageHandler.handleMessage(message);
    }
}
Example 53
Project: dragome-sdk-master  File: ClassTransformerDragomeWebSocketHandler.java View source code
@OnMessage
public String onMessage(String message, Session session) {
    return (String) executeMethod(getClassName2(), "onMessage", message, session);
}
Example 54
Project: drone-selfie-master  File: SocketEndpoint.java View source code
@OnMessage
public void receiveMessage(String message) {
}
Example 55
Project: liferay-portal-master  File: EncodeWebSocketClient.java View source code
@OnMessage
public void onMessage(Example example, Session session) throws InterruptedException {
    _blockingQueue.put(example);
}
Example 56
Project: restful-and-beyond-tut2184-master  File: ResponderServer.java View source code
@OnMessage
@StartsRequestScope
public void respond(String data, Session session) {
    System.out.println("Server Received " + data);
    RequestInvoker requestInvoker = CDI.current().select(RequestInvoker.class).get();
    requestInvoker.inRequestScope(session, data);
}
Example 57
Project: simple-websocket-client-master  File: EchoEndpoint.java View source code
@OnMessage
public void receiveTextMessage(String message, Session session) throws IOException {
    LOGGER.info("Received Text Message");
    session.getBasicRemote().sendText(message);
}
Example 58
Project: uaiMockServer-master  File: ChatClientEndpoint.java View source code
/**
     * Callback hook for Message Events. This method will be invoked when a
     * client send a message.
     *
     * @param message
     *            The text message
     */
@OnMessage
public void onMessage(String message) {
    if (this.messageHandler != null) {
        this.messageHandler.handleMessage(message);
    }
}
Example 59
Project: che-master  File: BasicWebSocketEndpoint.java View source code
@OnMessage
public void onMessage(String message, @PathParam("endpoint-id") String endpointId) {
    LOG.debug("Receiving a web socket message.");
    LOG.debug("Endpoint: {}", endpointId);
    LOG.debug("Message: {}", message);
    receiver.receive(endpointId, message);
}
Example 60
Project: DevTools-master  File: BasicWebSocketEndpoint.java View source code
@OnMessage
public void onMessage(String message, @PathParam("endpoint-id") String endpointId) {
    LOG.debug("Receiving a web socket message.");
    LOG.debug("Endpoint: {}", endpointId);
    LOG.debug("Message: {}", message);
    receiver.receive(endpointId, message);
}
Example 61
Project: knox-master  File: ProxyInboundSocket.java View source code
@OnMessage(maxMessageSize = Integer.MAX_VALUE)
public void onBackendMessage(final String message, final javax.websocket.Session session) {
    callback.onMessageText(message, session);
}
Example 62
Project: MaritimeCloud-master  File: ServerTransportJsr356Endpoint.java View source code
@OnMessage
public void onTextMessage(String textMessage) {
    transport.endpointOnTextMessage(textMessage);
}
Example 63
Project: servoy-client-master  File: NGClientEndpoint.java View source code
@Override
@OnMessage
public void incoming(String msg, boolean lastPart) {
    super.incoming(msg, lastPart);
}
Example 64
Project: javaee7-hol-master  File: ChatServer.java View source code
@OnMessage
public void message(String message, Session client) throws IOException, EncodeException {
    for (Session peer : peers) {
        peer.getBasicRemote().sendText(message);
    }
}
Example 65
Project: mojarra-master  File: Matrix.java View source code
@OnMessage
public void handleMessage(String message, Session session) throws IOException {
    logger.info("WS ENDPOINT BROADCASTING MESSAGE:" + message);
    for (Session nextSession : peers) {
        logger.info("BROADCASTING MESSAGE NEXT SESSION:" + nextSession);
        nextSession.getBasicRemote().sendText(message);
    }
}
Example 66
Project: hawkular-inventory-master  File: WebsocketEvents.java View source code
@OnMessage
public void handleMessage(String message, Session session) {
    WebsocketApiLogger.LOGGER.onMessage(session.getId(), message);
}
Example 67
Project: undertow.js-master  File: CDIInjectionProviderDependentTestCase.java View source code
@OnMessage
public void message(String message) {
    messages.add(message);
}
Example 68
Project: cloud-pubsub-samples-java-master  File: WebSocketInjectorStub.java View source code
/**
   * A callback when a message comes through a websocket connection.
   */
@OnMessage
public void onMessage(String message, Session session) {
    //    logger.info("Received ...." + message);
    handleMessage(message);
}
Example 69
Project: everrest-master  File: WSClient.java View source code
@OnMessage
public void processTextMessage(String message) {
    for (ClientMessageListener listener : listeners) {
        listener.onMessage(message);
    }
}
Example 70
Project: PerfCake-master  File: WebSocketSender.java View source code
/**
       * Receives incoming web socket messages.
       *
       * @param message
       *       Incomming message.
       * @param session
       *       Web socket session.
       */
@OnMessage
public void onMessage(final String message, final Session session) {
    if (logger.isTraceEnabled()) {
        logger.trace("Received message: " + message);
    }
}
Example 71
Project: tengi-master  File: WebsocketTransportTestCase.java View source code
@OnMessage
public void onMessage(ByteBuffer byteBuffer) throws Exception {
    ByteBuf buffer = Unpooled.wrappedBuffer(byteBuffer);
    channelReader.channelRead(this, buffer);
}
Example 72
Project: tern.java-master  File: NodejsTernServer.java View source code
@OnMessage
public void dispatchMessage(String data) {
    JsonObject value = Json.parse(data).asObject();
    String type = value.getString("type", null);
    JsonValue json = value.get("data");
    if (type != null && json != null) {
        NodejsTernServer.this.fireOnMessage(type, json);
    }
}
Example 73
Project: red5-websocket-master  File: WebSocketServerTest.java View source code
@OnMessage
public void onMessage(String message) {
    System.out.println("Received msg: " + message);
}