use of javax.websocket.Decoder.Binary in project jetty.project by eclipse.
the class BinaryWholeMessage method messageComplete.
@SuppressWarnings("unchecked")
@Override
public void messageComplete() {
super.finished = true;
byte[] data = out.toByteArray();
DecoderFactory.Wrapper decoder = msgWrapper.getDecoder();
Decoder.Binary<Object> binaryDecoder = (Binary<Object>) decoder.getDecoder();
try {
Object obj = binaryDecoder.decode(BufferUtil.toBuffer(data));
wholeHandler.onMessage(obj);
} catch (DecodeException e) {
throw new WebSocketException("Unable to decode binary data", e);
}
}
use of javax.websocket.Decoder.Binary in project tomcat70 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;
}
Aggregations