Getting a Uncaught TypeError: undefined is not a function
on my pusherTrigger method
It's a simple messaging system, where one user sends another user a message and the receiver should get a notification for it. I have a compose_message
action that is supposed push the message onto the channel private-incomingMessages
.
export default Ember.ObjectController.extend(window.EmberPusher.Bindings, window.EmberPusher.ClientEvents, {
content: {},
logPusherEvents: true,
PUSHER_SUBSCRIPTIONS: {'messageChannel': ['client-compose-message'],
'incomingMessages': ['client-user-messages']},
actions: {
compose_message: function(){
var self = this, content = this.get('messageContent');
self.get('pusher.connection').pusherTrigger('incomingMessages', 'client-user-messages', {'message': content}); //not registering pusherTrigger as a method
},
clientUserMessages: function(){
console.log("client user messages is working!");
}
});
Let me know if you need more info. Please help if you can!
Sorry, what is your question? You don't have the auth route on your backend.
You can only trigger client events on private channels so you'll need to use private channels ( I see you had them and then removed them ). See the Pusher client event docs .
You'll therefore need to authenticate your private channel and thus you'll need the /pusher/auth
endpoint.
In order to create the private-
channel name the EmberPusher docs suggested you build up the subscription hash in a controller init
function.
Ember.ObjectController.extend(window.EmberPusher.Bindings, window.EmberPusher.ClientEvents, {
init: {
// build subscription hash here
},
...
});
As per the EmberPusher docs you'll need to camelise
event names so I think compose_message
should be clientComposeMessage
.
Finally, the code for calling pusherTrigger
doesn't look right. The EmberPusher docs show:
this.pusherTrigger(this.get('channelName'), eventName, this.get('data'));
In your example it looks like pusherTrigger
is being called on the connection object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.