Closed jryebread closed 1 year ago
This is expected. If you have new subscribers (or removed subscribers), you need to rebind the socket as described here: https://github.com/crisp-im/node-crisp-api#realtime-events
Using: CrispClient.rebindSocket()
@valeriansaliou I tried calling rebindSocket() in my updatePlugin function:
await this.crispClient.plugin.rebindSocket();
I also tried await this.crispClient.rebindSocket();
both give an error. can you share an example of how I should be calling it please? the other crispAPI calls work
It is this.crispClient.rebindSocket
not this.crispClient.plugin.rebindSocket
. Check your local crispClient object.
I tried this.crispClient.rebindSocket
as well and it didn't work, said is not a function.
the local crispClient object is the same as new Crisp()
it doesn't actually show this as a function
declare class Crisp {
auth: {};
/**
* @private
* @type {string}
*/
private _tier;
/** @private */
private _rest;
/** @private */
private _rtm;
/** @private */
private _useragent;
/** @private */
private _emitter;
/** @private */
private _socket;
/** @private */
private _socketScheduler;
/** @private */
private _socketBindHooks;
/** @private */
private _boundEvents;
setRestHost: (host: string) => void;
setRtmHost: (host: string) => void;
setTier: (tier: string) => void;
authenticate: (identifier: string, key: string) => void;
authenticateTier: (tier: string, identifier: string, key: string) => void;
head: (resource: string, query: object, body: object) => any;
get: (resource: string, query: object) => any;
post: (resource: string, query: object, body: object) => any;
patch: (resource: string, query: object, body: object) => any;
put: (resource: string, query: object, body: object) => any;
delete: (resource: string, query: object, body: object) => any;
on: (event: string, callback: Function) => void;
_prepareRestUrl: (paths: any[]) => string;
_prepareServices: () => void;
_prepareResources: (serviceInstance: object, resources: any[]) => void;
_prepareSocket: (fnBindHook: Function) => void;
_request: (resource: string, method: string, query: object, body: object, resolve: Function, reject: Function) => void;
_emitAuthenticate: () => void;
}
Also tried setting RTM mode following https://github.com/crisp-im/node-crisp-api/blob/master/examples/events_webhooks.js but even that didn't work?
@valeriansaliou any ideas?
Hi, having an issue where new subscribers to my plugin, the listener isn't working for them,
this.crispClient.on("message:send", async (event) => {
Only listens for plugins already registered and I can't figure out why?
What can I do to fix this in my code? How can I unsubscribe and reset the listener when a new user subscribes to the plugin? :