mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-01 03:19:13 +00:00
JSR-356 Making PongMessage work with @OnMessage annotation
This commit is contained in:
parent
3e070f929e
commit
eb0d7da7f2
@ -161,6 +161,21 @@ public class JsrEvents<T extends Annotation, C extends EndpointConfig>
|
||||
onOpen.call(websocket,config);
|
||||
}
|
||||
|
||||
public void callPong(RemoteEndpoint.Async endpoint, Object websocket, ByteBuffer pong) throws DecodeException, IOException
|
||||
{
|
||||
if (onPong == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Object ret = onPong.call(websocket,pong);
|
||||
if (ret != null)
|
||||
{
|
||||
LOG.debug("returning: {}",ret);
|
||||
endpoint.sendObject(ret);
|
||||
}
|
||||
}
|
||||
|
||||
public void callText(RemoteEndpoint.Async endpoint, Object websocket, String text, boolean fin) throws DecodeException
|
||||
{
|
||||
if (onText == null)
|
||||
|
@ -213,6 +213,19 @@ public class JsrAnnotatedEventDriver extends AbstractJsrEventDriver implements E
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPong(ByteBuffer buffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
events.callPong(jsrsession.getAsyncRemote(),websocket,buffer);
|
||||
}
|
||||
catch (DecodeException | IOException e)
|
||||
{
|
||||
onFatalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReader(Reader reader)
|
||||
{
|
||||
|
@ -140,10 +140,15 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
|
||||
{
|
||||
pongBuf = ByteBuffer.allocate(0);
|
||||
}
|
||||
onPong(pongBuf);
|
||||
onPing(frame.getPayload());
|
||||
session.getRemote().sendPong(pongBuf);
|
||||
break;
|
||||
}
|
||||
case OpCode.PONG:
|
||||
{
|
||||
onPong(frame.getPayload());
|
||||
break;
|
||||
}
|
||||
case OpCode.BINARY:
|
||||
{
|
||||
onBinaryFrame(frame.getPayload(),frame.isFin());
|
||||
@ -195,6 +200,12 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
|
||||
{
|
||||
/* TODO: provide annotation in future */
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPing(ByteBuffer buffer)
|
||||
{
|
||||
/* TODO: provide annotation in future */
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openSession(WebSocketSession session)
|
||||
|
@ -51,6 +51,8 @@ public interface EventDriver extends IncomingFrames
|
||||
|
||||
public void onInputStream(InputStream stream);
|
||||
|
||||
public void onPing(ByteBuffer buffer);
|
||||
|
||||
public void onPong(ByteBuffer buffer);
|
||||
|
||||
public void onReader(Reader reader);
|
||||
|
Loading…
x
Reference in New Issue
Block a user