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
I've put together a package for defining controllers and handlers using inversify for a socket.io server (https://socket.io/) based heavily on the inversify-express-utils package you have.
@controller('/')exportclassOnlineStatusController{constructor(
@inject(SERVICE_TYPES.UserService)privateuserService: UserService){}
@handler(CONNECT_USER)privateasynchandleConnect(@socketId()socketId: string, @body()body: ConnectUserBody){const{userId}=body// save socketId and userId somewherethis.userService.setUserOnline(userId)}
@handler([SOCKET_IO_EVENT.DISCONNECT,DISCONNECT_USER])privateasynchandleDisconnect(@socketId()socketId: string){// retrieve userId given socketIdthis.userService.setUserOffline(userId)}}
It currently supports:
auto discovery and binding of controllers using @controller(namespace?: string) class decorator
auto registration of event handlers using the @handler(events: string | string[]) method decorator
@socketId(): string@socket(): SocketIO.Socket@body(): any param decorators.
optional debug and logging feature
optional redis adapter feature
If this is a repo you guys would be interested in bringing in to your org, then I'd be happy to write up a proper readme and maintain it for you. I can zip up and send over the code for you to check out.
Let me know!
The text was updated successfully, but these errors were encountered:
@mattwills8 hello, apologies for the late response, this is the first time i am seeing this issue, since i am triaging a bit.
That would be really cool. Is is posible to not limit it to socket-io. A lot of people also use ws and then if someone does a new package for ws then there would be at least 2 more packages.
Let me know if you are interested in that, and we will gladly add it here.
Hey guys, wasn't sure how else to get in contact.
I've put together a package for defining controllers and handlers using inversify for a socket.io server (https://socket.io/) based heavily on the inversify-express-utils package you have.
Setup looks like
with an example controller looking like
It currently supports:
@controller(namespace?: string)
class decorator@handler(events: string | string[])
method decorator@socketId(): string
@socket(): SocketIO.Socket
@body(): any
param decorators.If this is a repo you guys would be interested in bringing in to your org, then I'd be happy to write up a proper readme and maintain it for you. I can zip up and send over the code for you to check out.
Let me know!
The text was updated successfully, but these errors were encountered: