我正在使用signalR java客户端,我正在使用此方法连接主机 但是获得协商异常和connectionid returs null
connection = new HubConnection(host);
hub = connection.createHubProxy("Chat");
hub.subscribe(MainActivity.this);
hub.on("addChatMessage", new SubscriptionHandler() {
@Override
public void run() {
// TODO Auto-generated method stub
Log.e("test", "entered in hub.on method");
}
});
// connection.start();
SignalRFuture<Void> awaitConnection = connection.start();
try {
awaitConnection.get();
} catch (InterruptedException e) {
Log.e("<<<Exception>>>", ""+ e.toString() + "<<<>>>"
+ e.getMessage());
} catch (ExecutionException e) {
Log.e("<<<Exception>>>", "" + e.toString() + "<<<>>>"
+ e.getMessage());
}
Log.e("", "connectionId : "+ connection.getConnectionId());
答案 0 :(得分:0)
hub = connection.createHubProxy("wallpostChat");
hub.subscribe(MainActivity.this);
hub.on("addChatMessage", new SubscriptionHandler() {
@Override
public void run() {
// TODO Auto-generated method stub
Log.e("test", "entered in hub.on method");
}
});