} catch (IOException ioe) {
// Ignore
}
}
}
completion.onResult(new SendResult());
} else if (encoder instanceof Encoder.Binary) {
ByteBuffer msg = ((Encoder.Binary) encoder).encode(obj);
sendBytesByCompletion(msg, completion);
} else if (encoder instanceof Encoder.BinaryStream) {
OutputStream os = null;
try {
os = getSendStream();
((Encoder.BinaryStream) encoder).encode(obj, os);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException ioe) {
// Ignore
}
}
}
completion.onResult(new SendResult());
} else {
throw new EncodeException(obj, sm.getString(
"wsRemoteEndpoint.noEncoder", obj.getClass()));
}
} catch (EncodeException e) {
SendResult sr = new SendResult(e);
completion.onResult(sr);
} catch (IOException e) {
SendResult sr = new SendResult(e);
completion.onResult(sr);
}
}