watchparty icon indicating copy to clipboard operation
watchparty copied to clipboard

REFACTOR: Add Connection Class for user related events

Open bdbch opened this issue 4 years ago • 5 comments

This PR adds the connection class which handles user related events. I'm not sure if it should also handle all events coming from a connection and just call a function from the room so we have all events in one class?

bdbch avatar Jul 16 '20 08:07 bdbch

Yeah, I would like to keep the event handlers in one file to make them easier to find.

I'm actually not sure if we need to break this into its own class at all. Seems like it would be easier to reason about what each function does (act on a room, with socket in context) if it's in the room class.

howardchung avatar Jul 16 '20 09:07 howardchung

I'm not sure. Since the room already listens on connections on('connection') I'd thought it would be nice if each connection takes care of the events and updates it emits and listens on. For me the room class should actually contain logic for the video and chat states so we separate both concerns sockets, connections, events and video playback, playlist and chat/videochat.

What are your thoughts on that?

bdbch avatar Jul 16 '20 09:07 bdbch

Also we don't need to pass the socket to each method everytime since the class can be self referential on the socket variable.

bdbch avatar Jul 16 '20 09:07 bdbch

At some point as we scale to more events it would probably make sense to split them up based on what they are for. However right now I think the split is a bit arbitrary (name, picture, uid are kind of similar, but join/leaveVideo feel different).

It might make sense to go through the events and sort/group them by category. Maybe for now we can just rearrange them into blocks and label them with comments, and based on that decide on splitting them into classes.

howardchung avatar Jul 16 '20 09:07 howardchung

ooooooooooooh ok

asotel62102021 avatar May 12 '21 16:05 asotel62102021

Hey! Sorry for being so inactive. I'll close this one for now.

bdbch avatar Jun 25 '24 16:06 bdbch