@Override public Object sendMessage(Object message) { return channel.write(message, remoteAddress); }
@Override public Object sendMessage(Object message) { return channel.write(message, remoteAddress); }
/** * Utility method used to send a message to the server. Users can also use * datagramChannel.write(message, serverAddress) directly. * * @param datagramChannel * The channel on which the message is to be sent to remote * server. * @param message * The message to be sent. <b>NOTE</b> The message should be a * valid and encode-able by the encoders in the ChannelPipeline * of this server. * @return Returns a ChannelFuture which can be used to check the success of * this operation. <b>NOTE</b> Success in case of UDP means message * is sent to server. It does not mean that the server has received * it. */ public static ChannelFuture write(DatagramChannel datagramChannel, Object message, InetSocketAddress serverAddress) { return datagramChannel.write(message, serverAddress); }
ChannelFuture future = datagramChannel.write(event, serverAddress); future.addListener(new ChannelFutureListener()
@Override public Void call() throws InterruptedException { final List<Message> received = new ArrayList<Message>(); synchronized (this) { LOG.trace("BroadcastPeer CALL"); final long now = System.nanoTime(); handleTimeout(now, received); handleQueue(now); if (sentPacket != null && sentPacket.isEmpty()) sentPacket = null; if (isTimeToResned(now)) { if (sentPacket != null) { // if messages have been added tos sentPacket has changed, handleQueue sets lastSent to 0 assert !sendToServerInsteadOfMulticast; LOG.debug("BroadcastPeer {} multicasting packet {}", this, sentPacket); channel.write(sentPacket, multicastGroup); resend(now); } else if (!broadcasts.isEmpty()) { executor.schedule(this, getTimeout(), MILLISECONDS); } } } for (Message message : received) receive(message); LOG.trace("BroadcastPeer CALL DONE"); return null; }
if (isTimeToResned(now)) { // if messages have been added to sentPacket has changed, handleQueue sets lastSent to 0 LOG.debug("Peer {} sending packet {}", this, sentPacket); channel.write(sentPacket, nodeAddress); if (hasRequests) resend(now);
@Override protected void doNotify(GntpNotification notification) { GntpNotifyMessage message = new GntpNotifyMessage(notification, -1, getPassword(), isEncrypted()); datagramChannel.write(message, getGrowlAddress()); }
@Override protected void doRegister() { GntpMessage message = new GntpRegisterMessage(getApplicationInfo(), getPassword(), isEncrypted()); datagramChannel.write(message, getGrowlAddress()); getRegistrationLatch().countDown(); }