mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-01 11:29:29 +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);
|
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
|
public void callText(RemoteEndpoint.Async endpoint, Object websocket, String text, boolean fin) throws DecodeException
|
||||||
{
|
{
|
||||||
if (onText == null)
|
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
|
@Override
|
||||||
public void onReader(Reader reader)
|
public void onReader(Reader reader)
|
||||||
{
|
{
|
||||||
|
@ -140,10 +140,15 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
|
|||||||
{
|
{
|
||||||
pongBuf = ByteBuffer.allocate(0);
|
pongBuf = ByteBuffer.allocate(0);
|
||||||
}
|
}
|
||||||
onPong(pongBuf);
|
onPing(frame.getPayload());
|
||||||
session.getRemote().sendPong(pongBuf);
|
session.getRemote().sendPong(pongBuf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OpCode.PONG:
|
||||||
|
{
|
||||||
|
onPong(frame.getPayload());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case OpCode.BINARY:
|
case OpCode.BINARY:
|
||||||
{
|
{
|
||||||
onBinaryFrame(frame.getPayload(),frame.isFin());
|
onBinaryFrame(frame.getPayload(),frame.isFin());
|
||||||
@ -196,6 +201,12 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
|
|||||||
/* TODO: provide annotation in future */
|
/* TODO: provide annotation in future */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPing(ByteBuffer buffer)
|
||||||
|
{
|
||||||
|
/* TODO: provide annotation in future */
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openSession(WebSocketSession session)
|
public void openSession(WebSocketSession session)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +51,8 @@ public interface EventDriver extends IncomingFrames
|
|||||||
|
|
||||||
public void onInputStream(InputStream stream);
|
public void onInputStream(InputStream stream);
|
||||||
|
|
||||||
|
public void onPing(ByteBuffer buffer);
|
||||||
|
|
||||||
public void onPong(ByteBuffer buffer);
|
public void onPong(ByteBuffer buffer);
|
||||||
|
|
||||||
public void onReader(Reader reader);
|
public void onReader(Reader reader);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user