You need to add StringFilter, like in the sample https://github.com/GrizzlyNIO/grizzly-mirror/blob/2.3.x/samples/framework-samples/src/main/java/org/glassfish/grizzly/samples/echo/EchoClient.java
Grizzly - How to send a string to the client
-
01-07-2023 - |
Question
I can't seem to figure out how to send a simple string to the client. Every time I try it like this
@Override
public NextAction handleRead(FilterChainContext ctx) throws IOException {
ctx.write("test");
return ctx.getInvokeAction();
}
it throws an error:
java.lang.ClassCastException: java.lang.String cannot be cast to org.glassfish.grizzly.asyncqueue.WritableMessage
I tried implementing my own WritableMessage, which it then sends but it doesn't work. I can't figure out how to set it up properly, or if it's the right way.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow