在handler 類里面
/**
* 有資料時觸發
*/
@Override
protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
}
/**
* 建立連接后第一個執行
*/
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
ctx.channel().writeAndFlush(new TextWebSocketFrame("hello world"));
}
前端接收不到資料 ,在函式channelRead0里面發送就可以收到 這是怎么回事呢
uj5u.com熱心網友回復:
你的channelRead0中的代碼呢uj5u.com熱心網友回復:
不影響后面的發送嗎吧 兩個函式測驗的時候都是這句
ctx.channel().writeAndFlush(new TextWebSocketFrame("hello world"));
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/14363.html
標籤:Java SE
上一篇:彩色版
下一篇:求java開源工具計算IRR
