I have successfully implemented signalR client for android but my problem is to get return data from server. I can able to send messages from side and it is showing at other client when i am broadcasting but i am not getting the message. Can anybody help me how to get messages by hubproxy.on method.
String host = "serverlink";
connection = new HubConnection(host);
hub = connection.createHubProxy("myHub");
hub.subscribe(MainActivity.this);
hub.on("addChatMessage", new SubscriptionHandler() {
@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("test");
}
});
// connection.start();
SignalRFuture<Void> awaitConnection = connection.start();
try {
awaitConnection.get();
} catch (InterruptedException e) {
System.out.println("<<<Exception>>>" + e.toString() + "<<<>>>"
+ e.getMessage());
} catch (ExecutionException e) {
System.out.println("<<<Exception>>>" + e.toString() + "<<<>>>"
+ e.getMessage());
}
joinButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
hub.invoke("InformUserName", joinEditText.getText().toString()).get();
} catch (InterruptedException e) {
System.out.println("<<<Exception>>>" + e.toString()
+ "<<<>>>" + e.getMessage());
} catch (ExecutionException e) {
System.out.println("<<<Exception>>>" + e.toString()
+ "<<<>>>" + e.getMessage());
}
}
});
sendButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
hub.invoke("Send", joinEditText.getText().toString(), messEditText.getText().toString()).get();
} catch (InterruptedException e) {
System.out.println("<<<Exception>>>" + e.toString() + "<<<>>>"
+ e.getMessage());
} catch (ExecutionException e) {
System.out.println("<<<Exception>>>" + e.toString() + "<<<>>>"
+ e.getMessage());
}
}
});
hub.on is Not Calling how can i initialise subcriptionhandler