我需要 Pusher 上的私人频道,以便让一堆 Android 客户端能够相互通信。Pusher 是推荐给我的,虽然它真的很复杂。我已经多次阅读所有文档,所以我希望有人(Leggette 先生?)可以帮助我。
我已经在客户端上安装了 Pusher Android JAR,并且能够订阅我从“事件创建器”触发的公共频道(非常整洁),但是为了让私人频道正常工作,为了触发事件,我需要这个:
HttpAuthorizer authorizer = new HttpAuthorizer("http://example.com/some_auth_endpoint");
PusherOptions options = new PusherOptions().setAuthorizer(authorizer);
Pusher pusher = new Pusher( YOUR_APP_KEY, options );
根据http://pusher.com/docs/authenticating_users, HttpAuthorizer() 需要一个指向应用服务器的 URL,该应用服务器将使用 JSON 身份验证令牌进行响应。我是否必须设置自己的应用服务器来提供身份验证,例如https://raw.github.com/pusher/pusher-android-example/master/src/com/pusher/android/example/MainActivity 中的示例。 java,或者 Pusher 可以提供这个吗?这似乎是 Pusher 应该提供的东西。
在我的应用程序的 Ruby 服务器代码示例中(为什么没有 Java?)我看到了这个:Pusher.url = "http://{key}:{secret}@api.pusherapp.com/apps/{app_id}"
. 但是,此 URL 不存在。我在 HttpAuthorizer() 中尝试了它并得到了 java.io.FileNotFoundException。(我刚刚在设置下找到了“启用客户端事件”复选框 - 检查它没有帮助,但我猜这是一个重要的步骤。)
如果我必须设置自己的应用服务器进行身份验证,我想将 Java 与 GAE 一起使用。http://pusher.com/docs/authenticating_users#implementing_private_endpoints有一个 Python/GAE 示例,但没有 Java,我不知道 Python。有这方面的图书馆吗?https://github.com/marcbaechinger/gae-java-libpusher#会成功吗?似乎不会。