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);
}
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);
}
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);
}
Aggregations