Examples of TextMessage


Examples of org.xlightweb.TextMessage

               
            }

           
            public void onMessage(IWebSocketConnection webStream) throws IOException {
                TextMessage msg = webStream.readTextMessage();
                if (msg.toString().equalsIgnoreCase("GetDate")) {
                    webStream.writeMessage(new TextMessage(new Date().toString()));
                } else {
                    webStream.writeMessage(new TextMessage("unknown command (supported: GetDate)"));
                }
            }
           
           
            public void onDisconnect(IWebSocketConnection webStream) throws IOException {
               
            }
        }

       
        HttpServer server = new HttpServer(8876, new ServerHandler());
        server.start();
       
       
        HttpClient httpClient = new HttpClient();

        httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/WebSocketsExample"));
       
        IWebSocketConnection wsCon = httpClient.openWebSocketConnection("ws://localhost:" + server.getLocalPort() + "/WebSocketsExample", "mySubprotocol");
       
        wsCon.writeMessage(new TextMessage("GetDate"));
        TextMessage msg = wsCon.readTextMessage();
       
       
       
        httpClient.close();
       
View Full Code Here

Examples of us.b3k.kafka.ws.messages.TextMessage

        }

        private void sendText(String topic, byte[] message) {
            String messageString = new String(message, Charset.forName("UTF-8"));
            LOG.trace("XXX Sending text message to remote endpoint: {} {}", topic, messageString);
            remoteEndpoint.sendObject(transform.transform(new TextMessage(topic, messageString), session));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.