Search in sources :

Example 6 with PingFrame

use of com.webpieces.http2.api.dto.lowlevel.PingFrame in project webpieces by deanhiller.

the class TestHttp2Ping method testMarshalPingFrame.

@Test
public void testMarshalPingFrame() {
    PingFrame frame = new PingFrame();
    frame.setOpaqueData(0x10);
    byte[] data = parser.marshal(frame).createByteArray();
    String hexFrame = Util.toHexString(data);
    Assert.assertEquals(getPingFrame(), hexFrame);
}
Also used : PingFrame(com.webpieces.http2.api.dto.lowlevel.PingFrame) Test(org.junit.Test)

Example 7 with PingFrame

use of com.webpieces.http2.api.dto.lowlevel.PingFrame in project webpieces by deanhiller.

the class TestHttp2Ping method testMarshalPongFrame.

@Test
public void testMarshalPongFrame() {
    PingFrame frame = new PingFrame();
    frame.setOpaqueData(0x10);
    frame.setIsPingResponse(true);
    byte[] data = parser.marshal(frame).createByteArray();
    String hexFrame = Util.toHexString(data);
    Assert.assertEquals(getPongFrame(), hexFrame);
}
Also used : PingFrame(com.webpieces.http2.api.dto.lowlevel.PingFrame) Test(org.junit.Test)

Example 8 with PingFrame

use of com.webpieces.http2.api.dto.lowlevel.PingFrame in project webpieces by deanhiller.

the class Level7MarshalAndPing method sendPing.

// public XFuture<Void> sendControlFrameToClient(Http2Msg msg) {
// return finalLayer.sendControlFrameToClient(msg);
// }
public XFuture<Void> sendPing() {
    PingFrame ping = new PingFrame();
    ping.setOpaqueData(8L);
    XFuture<Void> newFuture = new XFuture<>();
    boolean wasSet = pingFutureRef.compareAndSet(null, newFuture);
    if (!wasSet) {
        throw new IllegalStateException(key + "You must wait until the first ping you sent is complete.  2nd ping=" + ping);
    }
    return sendFrameToSocket(ping).thenCompose(c -> newFuture);
}
Also used : PingFrame(com.webpieces.http2.api.dto.lowlevel.PingFrame) XFuture(org.webpieces.util.futures.XFuture)

Aggregations

PingFrame (com.webpieces.http2.api.dto.lowlevel.PingFrame)8 Test (org.junit.Test)4 DataWrapper (org.webpieces.data.api.DataWrapper)3 ByteBuffer (java.nio.ByteBuffer)2 ConnectionException (com.webpieces.http2.api.dto.error.ConnectionException)1 FrameHeaderData (com.webpieces.http2parser.impl.FrameHeaderData)1 XFuture (org.webpieces.util.futures.XFuture)1