我想将用户添加到signalR组,但它说失败了。 我的android代码在组中添加用户如下
HubConnection connection = new HubConnection("http://www.planetskool.in/");
HubProxy proxy = connection.createHubProxy("ChatHub");
try {
//Log.d(TAG, "connection.start()...");
SignalRFuture<Void> awaitConnection = connection.start();
// Log.d(TAG, "started");
awaitConnection.get();
// Log.d(TAG, "got");
} catch (InterruptedException e) {
/// Log.e(TAG,"InterruptedException");
e.printStackTrace();
} catch (ExecutionException e) {
//Log.e(TAG, "ExecutionException");
e.printStackTrace();
}
SignalRFuture<Void> isGroupCreated2 = proxy.invoke("JoinGroup", loginUserInfoId);
Log.d("isGroupCreated", "isGroupCreated2 = " + proxy.invoke("JoinGroup", loginUserInfoId).isDone());
proxy.on("broadcastMessage",
new SubscriptionHandler1<String>() {
@Override
public void run(final String status) {
//getApplicationContext().runOnUiThread(new Runnable() {
//public void run() {
Log.d("SignalRResult=", status);
if(status.toUpperCase().equals("False".toUpperCase())) {
new SyncMessageFromServer().execute();
}
else {
new SyncGroupMessageFromServer().execute();
}
// }
//});
}
}
, String.class);
和MVC Web应用程序中的ChatHub中的代码是
public Task JoinGroup(string groupName)
{
return Groups.Add(Context.ConnectionId, groupName);
}
public void SendAll(string rUId, string message)
{
Clients.Group(rUId).broadcastMessage(message);
}
如何使其向特定用户发送通知