NetSocketInternal#writeMessage(Object) should return a Future<Void> and not be fluent

This commit is contained in:
Julien Viet
2019-10-08 10:25:30 +02:00
parent 1ab9884cb2
commit 707ad8c1bb
2 changed files with 6 additions and 4 deletions

View File

@@ -120,12 +120,13 @@ public class NetSocketImpl extends ConnectionBase implements NetSocketInternal {
}
@Override
public synchronized NetSocketInternal writeMessage(Object message) {
public synchronized Future<Void> writeMessage(Object message) {
if (closed) {
throw new IllegalStateException("Socket is closed");
}
writeToChannel(message);
return this;
Promise<Void> promise = Promise.promise();
writeMessage(message, promise);
return promise.future();
}
@Override

View File

@@ -14,6 +14,7 @@ package io.vertx.core.net.impl;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.net.NetSocket;
@@ -56,7 +57,7 @@ public interface NetSocketInternal extends NetSocket {
* @param message the message to write, it should be handled by one of the channel pipeline handlers
* @return a reference to this, so the API can be used fluently
*/
NetSocketInternal writeMessage(Object message);
Future<Void> writeMessage(Object message);
/**
* Like {@link #writeMessage(Object)} but with an {@code handler} called when the message has been written