【发布时间】:2017-09-01 05:22:02
【问题描述】:
我正在使用此代码(如 Autobahn 演示的 ExampleClient 所示)连接客户端:
ExecutorService executor = Executors.newSingleThreadExecutor();
session = new Session(executor);
session.addOnConnectListener(this);
session.addOnJoinListener(this);
session.addOnLeaveListener(this);
session.addOnDisconnectListener(this);
// Now create a transport list to try and add transports to it.
// In our case, we currently only have Netty based WAMP-over-WebSocket.
List<ITransport> transports = new ArrayList<>();
transports.add(new NettyTransport("wss://xxxxxxx.com/wss2/", executor));
// Now provide a list of authentication methods.
// We only support anonymous auth currently.
List<IAuthenticator> authenticators = new ArrayList<>();
authenticators.add(new AnonymousAuth());
// finally, provide everything to a Client instance and connect
Client client = new Client(transports, executor);
client.add(session, mLiveStream.streamName, authenticators);
client.connect();
但是 onConnect 回调永远不会被调用。
【问题讨论】: