You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I want to let server receive client response when emit an event, and i found it can achieve in socket.io via acknowledgements. But I failed to implement with feathers service, but succeeded with socket.io socket api. Could someone help that how can I implement it in feathers way? Thank you!!!
Here is how it implement in service, but failed:
// serverexportclassTestService<ServiceParamsextendsTestParams=TestParams>extendsEventEmitter// import from node:eventsimplementsServiceInterface<Test,TestData,ServiceParams>{constructor(publicoptions: TestServiceOptions){super()}asynccreate(data: TestData,params?: ServiceParams): Promise<Test>{// client listener is not triggered!this.emit('testEvent',1234,(res: any)=>{console.log(res)})// client listener catch it !// this.emit('task', 1234)returndata}}// clientapp.service('test').on('testEvent',(data: any,cb: any)=>{console.log('event data',data)cb({received: true})})
I try doing the same using socket as below, it works as expected.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi! I want to let server receive client response when emit an event, and i found it can achieve in socket.io via acknowledgements. But I failed to implement with feathers service, but succeeded with socket.io socket api. Could someone help that how can I implement it in feathers way? Thank you!!!
Here is how it implement in service, but failed:
I try doing the same using socket as below, it works as expected.
Beta Was this translation helpful? Give feedback.
All reactions