@maxim_goh wrote:
Hello, I try to use Akka Http server with websocket handling in Java code.
I’v used a handleWebSocketMessages directive as is in the akka doc. site:
https://doc.akka.io/docs/akka-http/current/server-side/websocket-support.htmlThe problem is when the message is not stricted (long text) I cannot get a text message of the client (I tried to call TextMessage.create(source).getStrictText())
The code of handleTextMessage fuctions is:
public static TextMessage handleTextMessage(TextMessage msg) {
String msgText = “”;
if (msg.asTextMessage().isStrict())
{
msgText = msg.asTextMessage().getStrictText();
} else {
Source<String,NotUsed> source = Source.single("").concat(msg.asTextMessage().getStreamedText());
msgText = TextMessage.create(source).getStrictText();
//handling of msgText …
}
}
How can I extract the text message?
Thanks.
Posts: 1
Participants: 1