Search in sources :

Example 1 with BinaryStream

use of jakarta.websocket.Decoder.BinaryStream in project tomcat by apache.

the class PojoMessageHandlerWholeBinary method decode.

@Override
protected Object decode(ByteBuffer message) throws DecodeException {
    for (Decoder decoder : decoders) {
        if (decoder instanceof Binary) {
            if (((Binary<?>) decoder).willDecode(message)) {
                return ((Binary<?>) decoder).decode(message);
            }
        } else {
            byte[] array = new byte[message.limit() - message.position()];
            message.get(array);
            ByteArrayInputStream bais = new ByteArrayInputStream(array);
            try {
                return ((BinaryStream<?>) decoder).decode(bais);
            } catch (IOException ioe) {
                throw new DecodeException(message, sm.getString("pojoMessageHandlerWhole.decodeIoFail"), ioe);
            }
        }
    }
    return null;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BinaryStream(jakarta.websocket.Decoder.BinaryStream) Binary(jakarta.websocket.Decoder.Binary) IOException(java.io.IOException) Decoder(jakarta.websocket.Decoder) DecodeException(jakarta.websocket.DecodeException)

Aggregations

DecodeException (jakarta.websocket.DecodeException)1 Decoder (jakarta.websocket.Decoder)1 Binary (jakarta.websocket.Decoder.Binary)1 BinaryStream (jakarta.websocket.Decoder.BinaryStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1