客戶端session.setAttribute服務(wù)端getAttribute = null
@Override
public void sessionOpened(IoSession session) throws Exception {
? ?session.setAttribute("user","213");
? ?mSessionManager.setmSession(session);
}
@Override
public void sessionCreated(IoSession session) throws Exception {
? ?super.sessionCreated(session);
? ?System.out.println("創(chuàng)建連接");
? ? String user = (String) session.getAttribute("user");
? ?session.write("d->"+user);
}
2017-01-18
這個應(yīng)該是只能在一端實(shí)現(xiàn)吧?客戶端設(shè)置只能在客戶端讀取