是否可以通过Spring Websocket接收和发送二进制消息?
@Controller
public class GreetingController {
@MessageMapping("/channels/{channelId}")
@SendTo("/topic/{channelId}/greetings")
public Greeting greeting(HelloMessage message, @PathParam("channelId") String channelId) throws Exception {
Thread.sleep(1000); // simulated delay
System.out.println("Channel: " + channelId);
System.out.println("Message Name: " + message.getName());
return new Greeting("Hello, " + HtmlUtils.htmlEscape(message.getName()) + "!");
}
}
这里的代码是一个简单的WebSocket控制器,它仅接受来自客户端的文本,可以接受二进制消息怎么办? (用于视频和音频二进制块)