}
}
else if (encoder instanceof Encoder.TextStream)
{
Encoder.TextStream etxt = (Encoder.TextStream)encoder;
SendHandlerWriteCallback callback = new SendHandlerWriteCallback(handler);
try (MessageWriter writer = new MessageWriter(session))
{
writer.setCallback(callback);
etxt.encode(data,writer);
return;
}
catch (EncodeException | IOException e)
{
handler.onResult(new SendResult(e));
}
}
else if (encoder instanceof Encoder.Binary)
{
Encoder.Binary ebin = (Encoder.Binary)encoder;
try
{
ByteBuffer buf = ebin.encode(data);
sendBinary(buf,handler);
return;
}
catch (EncodeException e)
{
handler.onResult(new SendResult(e));
}
}
else if (encoder instanceof Encoder.BinaryStream)
{
Encoder.BinaryStream ebin = (Encoder.BinaryStream)encoder;
SendHandlerWriteCallback callback = new SendHandlerWriteCallback(handler);
try (MessageOutputStream out = new MessageOutputStream(session))
{
out.setCallback(callback);
ebin.encode(data,out);
return;