Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions android/src/main/java/com/peel/react/TcpSocketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,19 @@ public void listen(final Integer cId, final String host, final Integer port) thr
}

mServer.listen(InetAddress.getByName(host), port, new ListenCallback() {
InetSocketAddress localAddress = socketAddress;

@Override
public void onListening(AsyncServerSocket socket) {
mClients.put(cId, socket);

if(socketAddress.getPort() != socket.getLocalPort()) {
localAddress = new InetSocketAddress(socketAddress.getAddress(), socket.getLocalPort());
}

TcpSocketListener listener = mListener.get();
if (listener != null) {
listener.onConnect(cId, socketAddress);
listener.onConnect(cId, localAddress);
}
}

Expand All @@ -97,7 +103,7 @@ public void onAccepted(AsyncSocket socket) {
mClients.put(mInstances, socket);

AsyncNetworkSocket socketConverted = Util.getWrappedSocket(socket, AsyncNetworkSocket.class);
InetSocketAddress remoteAddress = socketConverted != null ? socketConverted.getRemoteAddress() : socketAddress;
InetSocketAddress remoteAddress = socketConverted != null ? socketConverted.getRemoteAddress() : localAddress;

TcpSocketListener listener = mListener.get();
if (listener != null) {
Expand Down