@Override public ChannelHandler writeAndFlush(Object msg) { WriteFuture writeFuture = session.write(msg); return new MinaChannelHandler(writeFuture); }
@Override public ChannelHandler writeAndFlush(Object msg) { WriteFuture writeFuture = session.write(msg); return new MinaChannelHandler(writeFuture); }
private void deliverRawText0(String text){ boolean errorDelivering = false; IoBuffer buffer = IoBuffer.allocate(text.length()); buffer.setAutoExpand(true); try { //Charset charset = Charset.forName(CHARSET); //buffer.putString(text, charset.newEncoder()); buffer.put(text.getBytes(StandardCharsets.UTF_8)); if (flashClient) { buffer.put((byte) '\0'); } buffer.flip(); ioSessionLock.lock(); try { ioSession.write(buffer); } finally { ioSessionLock.unlock(); } } catch (Exception e) { Log.debug("Error delivering raw text:\n" + text, e); errorDelivering = true; } // Attempt to close the connection if delivering text fails. if (errorDelivering) { close(); } }
ioSession.write(buffer); } finally { ioSessionLock.unlock();
/** {@inheritDoc} */ @Override public void messageReceived(NextFilter next, IoSession session, Object message) throws Exception { // Create forwarding IO session IoSession forward = (IoSession) session.getAttribute(FORWARD_KEY); if (forward != null && forward.isConnected()) { if (message instanceof IoBuffer) { final IoBuffer buf = (IoBuffer) message; if (log.isDebugEnabled()) { log.debug("[{}] RAW >> {}", name, buf.getHexDump()); } IoBuffer copy = IoBuffer.allocate(buf.limit()); int limit = buf.limit(); copy.put(buf); copy.flip(); forward.write(copy); buf.flip(); buf.position(0); buf.limit(limit); } } next.messageReceived(session, message); }
if (s1 != null) { session.write(s1); } else { log.warn("Client was rejected due to invalid handshake");
if (s1 != null) { session.write(s1); } else { log.warn("Client was rejected due to invalid handshake");
/** * @see IoSession#write(Object) */ public WriteFuture write(Object message) { WriteFuture future = wrappedSession.write(message); this.lastReply = (FtpReply) message; return future; }
/** * @see IoSession#write(Object, SocketAddress) */ public WriteFuture write(Object message, SocketAddress destination) { WriteFuture future = wrappedSession.write(message, destination); this.lastReply = (FtpReply) message; return future; }
logger.debug("SEND[{}]: {} bytes: {}", new Object[]{ line.getSession().getId(), bytes.length, msg}); line.getSession().write(buffer).addListener(onWriteComplete); logger.debug("SEND[{}]: {} bytes: {}", new Object[]{ session.getId(), bytes.length, msg}); session.write(buffer).addListener(onWriteComplete);
private synchronized void write(IoBuffer buf) throws IOException { checkClosed(); WriteFuture future = session.write(buf); lastWriteFuture = future; }
/** * 发送消息 * * @param data */ public void sendMsg(String data) { if (mSession != null && mSession.isConnected()) { mSession.write(data); } } /**
public void sendMsg(Object message) { IoSession se = getSession(); if (se != null) { se.write(message); } else if (getChannel() != null) { getChannel().writeAndFlush(message); } else { log.warn("服务器:" + name + "连接会话为空"); } }
/** {@inheritDoc} */ @Override public void sessionOpened(IoSession session) throws Exception { LOG.info("Session opened"); if(m_conversation != null && m_conversation.hasBanner()) { LOG.info("Sending Banner: {} \n", m_conversation.getBanner()); session.write(m_conversation.getBanner()); } }
public void write(Message msg, MessageResponseHandler responseHandler) { if ( responseHandler != null ) { addResponseHandler( msg.getResponseId(), responseHandler ); } this.session.write( msg ); }
/** * Send the result to the consumer. If the consumer has disconnected, we fail back to the queue. */ private void sendResult( SearchResultEntry searchResultEntry, Entry entry, EventType eventType, SyncStateValue syncStateValue ) { searchResultEntry.addControl( syncStateValue ); LOG.debug( "sending event {} of entry {}", eventType, entry.getDn() ); WriteFuture future = session.getIoSession().write( searchResultEntry ); // Now, send the entry to the consumer handleWriteFuture( future, entry, eventType ); }
public void onServerConnected(MsgPacket msgPacket) { IoSession session = (IoSession) msgPacket.getOtherData(); System.out.println("接到消息:" + msgPacket.getMsgOpCode()); TestC.Builder builder = TestC.newBuilder(); builder.setName("你好啊"); TcpPacket pt = new TcpPacket(TestTCode.TESTC, builder.build()); session.write(pt); }
@Override public void sentOneWay(final Request request) throws Exception { ConnectFuture connect = super.getConnect(request); if (connect != null && connect.isConnected()) { RpcFuture rpcFuture = new RpcFuture(request); connect.addListener(new AbstractClient.FutureListener(rpcFuture)); connect.getSession().write(request); } else { throw new IllegalArgumentException("[JobX] MinaRPC channel not active. request id:" + request.getId()); } }
/** * 发送带ID的消息 * * @param object */ public void sendIdMsg(Object object) { if (getSession() != null && getSession().isConnected()) { getSession().write(new IDMessage(session, object, rid)); } else if (getChannel() != null && getChannel().isActive()) { getChannel().writeAndFlush(new IDMessage(channel, object, rid, null)); } }
@Override public void sessionOpened(IoSession session) throws Exception { Object request = getConversation().getRequest(); if(!getConversation().hasBanner() && request != null) { session.write(request); }else if(!getConversation().hasBanner() && request == null) { LOG.info("TCP session was opened, no banner was expected, and there are no more pending requests. Setting service detection to true."); getFuture().setServiceDetected(true); session.close(true); } }