Car*_* G. 2 java asp.net asp.net-mvc android signalr
我正在使用Asp Mvc,SignalR和Android Studio(带有Signalr Java Cliente),现在一切都很好。
我可以使用android应用程序中的signalr发送和接收简单对象,但是现在我想接收对象列表,但是我不知道该怎么做,这是我的代码:
//Both side Android Client and Server, when i send a category to android works.
public class Category
{
private int Id;
private String Name;
getters...
setters..
}
Run Code Online (Sandbox Code Playgroud)
在我的集线器(asp .net mvc 5)中,我有此方法:
public void Categories()
{
var categories = contexto.Categories.ToList()
hubContext.Clients.All.getCategories(categories);
}
Run Code Online (Sandbox Code Playgroud)
当我发送时仅使用类别即可。像这样:
//THIS WORKS
hubProxy.on("getCategory", new SubscriptionHandler1<Category>() {
@Override
public void run(final Category category) {
MainActivity.this.runOnUiThread(new Runnable() {
public void run() {
//....
}
});
}
},Categories.class);
Run Code Online (Sandbox Code Playgroud)
但是我想使用列表,例如:
hubProxy.on("getCategories", new SubscriptionHandler1<List<Categories>>() {
@Override
public void run(final List<Categories> categories) {
MainActivity.this.runOnUiThread(new Runnable() {
public void run() {
//....
}
});
}
},List<Categories.class>); //HERE IS MY PROBLEM
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
648 次 |
| 最近记录: |