尝试了几个选项后,我无法在Android应用程序上收到所有SignalR消息.在我看来它似乎是与LongPollingTransport相关的东西,但我找不到解决方案...我收到所有的longPolling消息,但有时它进入处理程序,有时它尝试再次连接到服务器而不进入处理程序方法.
我试着按照这里的例子.
代码很简单:
public void startNewSignalR(){
Platform.loadPlatformComponent(new AndroidPlatformComponent());
// Create a new console logger
Logger logger = new Logger() {
@Override
public void log(String message, LogLevel level) {
System.out.println(message);
}
};
Uri signalRSource = Uri.parse(serverUrl);
HubConnection connection = new HubConnection(signalRSource.toString(), "", true, logger);
eventHub = connection.createHubProxy("eventHub");
connection.error(new ErrorCallback() {
@Override
public void onError(Throwable error) {
System.err.println("There was an error communicating with the server.");
System.err.println("Error detail: " + error.toString());
error.printStackTrace(System.err);
}
});
// Subscribe to the connected event
connection.connected(new …Run Code Online (Sandbox Code Playgroud)