I am trying to use the examples from here so far this is what I have setup
// angularjs
// JS
var presenceClient = new Pusher('API_KEY', {
authEndpoint: apiServer + "/presence_auth",
authTransport: 'jsonp',
encrypted: true
})
var c = pusher.subscribe("presence-testchan")
Utils.log(c.members.count) // 0
Utils.log("000============")
c.bind('pusher:subscription_succeeded', function(members) {
Utils.log("succeeded?")
Utils.log(members)
})
// golang and the presence endpoint
func Presence(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
params, _ := GetBytes(r.URL.String())
presenceData := pusher.MemberData{
UserId: database.GenerateStrObjID(),
UserInfo: map[string]string{
"twitter": "pusher",
},
}
response, err := PusherClient.AuthenticatePresenceChannel(params, presenceData)
if err != nil {
panic(err)
}
respondToJSON(w, string(response))
}
func respondToJSON(w http.ResponseWriter, data interface{}) {
r := render.New()
r.JSON(w, http.StatusOK, data)
}
I guess that is the basic form. but I don't get any members count?. I can get a response from the API with
"{\"auth\":\"7d6e393c49c579c43a0c:6cd45662ef57fbc3ab16d8052c43bf95e7415846f736c2499bac7628ca3b75bc\",\"channel_data\":\"{\\\"user_id\\\":\\\"56f9e5ffcc1cb466a624a3cf\\\",\\\"user_info\\\":{\\\"twitter\\\":\\\"pusher\\\"}}\"}"
but has error
Uncaught SyntaxError: Unexpected token :
Am I missing something or my setup is wrong?