【发布时间】:2017-05-22 11:58:02
【问题描述】:
我在 android 中的私人频道订阅有问题。 这是我的代码
HashMap<String, String> headers = new HashMap<>();
headers.put("Authorization", code);
headers.put("Content-Type", "application/x-www-form-urlencoded");
headers.put("Accept", "application/json");
final HttpAuthorizer authorizer = new HttpAuthorizer("My URL");
authorizer.setHeaders(headers);
PusherOptions options = new PusherOptions()
.setEncrypted(true)
.setCluster("ap2")
.setAuthorizer(authorizer);
final Pusher pusher = new Pusher("KEY", options);
pusher.connect(new ConnectionEventListener() {
@Override
public void onConnectionStateChange(ConnectionStateChange change) {
}
@Override
public void onError(String message, String code, Exception e) { }
}, ConnectionState.ALL);
PrivateChannel channel = pusher.subscribePrivate(channelName);
channel.bind("message-sent", new PrivateChannelEventListener() {
@Override
public void onAuthenticationFailure(String string, Exception ex) {}
@Override
public void onSubscriptionSucceeded(String string) {
}
@Override
public void onEvent(String string, String string1, String string2) {}});
pusher.connect();
这会创建成功连接,但在订阅中它确实返回了任何结果。 请帮我解决这个问题。
【问题讨论】: