diff --git a/src/main/java/io/vertx/core/net/impl/NetSocketImpl.java b/src/main/java/io/vertx/core/net/impl/NetSocketImpl.java index bfe4c4502..831245798 100644 --- a/src/main/java/io/vertx/core/net/impl/NetSocketImpl.java +++ b/src/main/java/io/vertx/core/net/impl/NetSocketImpl.java @@ -120,12 +120,13 @@ public class NetSocketImpl extends ConnectionBase implements NetSocketInternal { } @Override - public synchronized NetSocketInternal writeMessage(Object message) { + public synchronized Future writeMessage(Object message) { if (closed) { throw new IllegalStateException("Socket is closed"); } - writeToChannel(message); - return this; + Promise promise = Promise.promise(); + writeMessage(message, promise); + return promise.future(); } @Override diff --git a/src/main/java/io/vertx/core/net/impl/NetSocketInternal.java b/src/main/java/io/vertx/core/net/impl/NetSocketInternal.java index 8c69f7db7..605a9245c 100644 --- a/src/main/java/io/vertx/core/net/impl/NetSocketInternal.java +++ b/src/main/java/io/vertx/core/net/impl/NetSocketInternal.java @@ -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 writeMessage(Object message); /** * Like {@link #writeMessage(Object)} but with an {@code handler} called when the message has been written