ii7mood / LiveMood

Follow your favourite Twitch / YouTube streamers and recieve notifications of their streams through a number of outlets!
1 stars 0 forks source link

[rework] Writing Listeners #11

Open ii7mood opened 4 weeks ago

ii7mood commented 4 weeks ago

As it stands writing new Listeners is confusing as hell.

I want to offload any socket* related processing to a Listener Controller and make receiving data a single function call that an also be executed on a separate thread. With this I will also write documentation and whatnot.

ii7mood commented 3 weeks ago

I thought about it for a bit and came up with something that I think works:

We will create a ListenerC (ListenerController) class that will have two definitions; one in server.py; and another in ListenerC.py.

A Listener would import ListenerC.py and register itself then listen for data; something like: ListenerC.register(ip, port, identity) ListenerC.listen()

server.py will be using two separate threads: one to listen for registrations and another to broadcast data to all listeners. This makes managing connections a lot easier and receiving data would literally take two lines as opposed to the abomination we are doing right now.

There are still smaller details that need to be ironed out, i.e: 1) Should I create a connection for each Listener and maintain it throughout the program or should I create a connection for a Listener, send data, then close it and repeat?

2) Should I make the server wait for an acknowledgement from the Listener (that it successfully processed the data) or no?

I will probably question more things as I actually start implementing this. For now I wrote a proof of concept that seems to work pretty well actually. Still in the designing phase.

ii7mood commented 3 weeks ago

Called for National Service. Bravo six going dark (for the next couple of months :] )