Package org.eclipse.jetty.websocket.api

Examples of org.eclipse.jetty.websocket.api.RemoteEndpoint


            cliSock.assertWasOpened();
            cliSock.assertNotClosed();

            Assert.assertThat("client.connectionManager.sessions.size",client.getConnectionManager().getSessions().size(),is(1));

            RemoteEndpoint remote = cliSock.getSession().getRemote();
            remote.sendStringByFuture("Hello World!");
            if (remote.getBatchMode() == BatchMode.ON)
                remote.flush();
            srvSock.echoMessage(1,500,TimeUnit.MILLISECONDS);
            // wait for response from server
            cliSock.waitForMessage(500,TimeUnit.MILLISECONDS);

            cliSock.assertMessage("Hello World!");
View Full Code Here


                latch.countDown();
            }
        };
        try (Session session = client.connect(adapter, uri).get())
        {
            RemoteEndpoint remote = session.getRemote();

            Future<Void> future = remote.sendStringByFuture("batch_mode_on");
            // The write is aggregated and therefore completes immediately.
            future.get(1, TimeUnit.MICROSECONDS);

            // Wait for the echo.
            Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
View Full Code Here

        try
        {
            LOG.debug("Writing {} messages to connection {}",messageCount);
            LOG.debug("Artificial Slowness {} ms",slowness);
            Future<Void> lastMessage = null;
            RemoteEndpoint remote = session.getRemote();
            while (m.get() < messageCount)
            {
                lastMessage = remote.sendStringByFuture(message + "/" + m.get() + "/");

                m.incrementAndGet();

                if (slowness > 0)
                {
                    TimeUnit.MILLISECONDS.sleep(slowness);
                }
            }
            if (remote.getBatchMode() == BatchMode.ON)
                remote.flush();
            // block on write of last message
            if (lastMessage != null)
                lastMessage.get(2,TimeUnit.MINUTES); // block on write
        }
        catch (Exception e)
View Full Code Here

            cliSock.assertWasOpened();
            cliSock.assertNotClosed();

            Assert.assertThat("client.connectionManager.sessions.size",client.getConnectionManager().getSessions().size(),is(1));

            RemoteEndpoint remote = cliSock.getSession().getRemote();
            remote.sendStringByFuture("Hello World!");
            if (remote.getBatchMode() == BatchMode.ON)
                remote.flush();
            srvSock.echoMessage(1,500,TimeUnit.MILLISECONDS);
            // wait for response from server
            cliSock.waitForMessage(500,TimeUnit.MILLISECONDS);
           
            Set<WebSocketSession> open = client.getOpenSessions();
View Full Code Here

        }

        try
        {
            // echo the data back
            RemoteEndpoint remote = getRemote();
            remote.sendString(message);
            if (remote.getBatchMode() == BatchMode.ON)
                remote.flush();
        }
        catch (IOException e)
        {
            throw new RuntimeIOException(e);
        }
View Full Code Here

        ByteBuffer buf2 = data.slice();

        buf1.limit(half);
        buf2.position(half);

        RemoteEndpoint remote = session.getRemote();
        try
        {
            switch (frame.getType())
            {
                case BINARY:
                    remote.sendBytes(buf1,null);
                    remote.sendBytes(buf2,null);
                    break;
                case TEXT:
                    // NOTE: This impl is not smart enough to split on a UTF8 boundary
                    remote.sendString(BufferUtil.toUTF8String(buf1),null);
                    remote.sendString(BufferUtil.toUTF8String(buf2),null);
                    break;
                default:
                    throw new IOException("Unexpected frame type: " + frame.getType());
            }
        }
View Full Code Here

            // wait for connect
            Session session = fut.get(3,TimeUnit.SECONDS);

            // Generate text frame
            String msg = "this is an echo ... cho ... ho ... o";
            RemoteEndpoint remote = session.getRemote();
            remote.sendString(msg);
            if (remote.getBatchMode() == BatchMode.ON)
                remote.flush();

            // Read frame (hopefully text frame)
            clientSocket.messages.awaitEventCount(1,500,TimeUnit.MILLISECONDS);
            EventQueue<String> captured = clientSocket.messages;
            Assert.assertThat("Text Message",captured.poll(),is(msg));
View Full Code Here

        if (!session.isOpen())
        {
            LOG.warn("Session is closed");
            return;
        }
        RemoteEndpoint remote = session.getRemote();
        remote.sendBytes(ByteBuffer.wrap(buf, offset, length), null);
        if (remote.getBatchMode() == BatchMode.ON)
            remote.flush();
    }
View Full Code Here

            // wait for connect
            Session session = fut.get(5,TimeUnit.SECONDS);

            // Generate text frame
            RemoteEndpoint remote = session.getRemote();
            remote.sendString("session.isSecure");
            if (remote.getBatchMode() == BatchMode.ON)
                remote.flush();

            // Read frame (hopefully text frame)
            clientSocket.messages.awaitEventCount(1,500,TimeUnit.MILLISECONDS);
            EventQueue<String> captured = clientSocket.messages;
            Assert.assertThat("Server.session.isSecure",captured.poll(),is("session.isSecure=true"));
View Full Code Here

        if (!session.isOpen())
        {
            LOG.warn("Session is closed");
            return;
        }
        RemoteEndpoint remote = session.getRemote();
        remote.sendString(message, null);
        if (remote.getBatchMode() == BatchMode.ON)
            remote.flush();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.websocket.api.RemoteEndpoint

Copyright © 2018 www.massapicom. 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.