It’s always something

Something you forgot. While taking a bio break I was reflecting on the api, eve, and how my angular webui would interface with it. Then it hit me, eve can’t update the view-model. There’s no code to push anything to the client. Which is really like half of the design goal right there, and me with absolutely zero plan for it.

So, still losing weight, I quickly searched through protocols. While there are push notifications for server=>client communications, but they are basically handled by the browser in little popups and toasts. Http2.0 has a “push” system, but it’s basically just for serving files before the client asks for them. A really neat feature that I will have to remember to setup once the webui is working. I came to the conclusion that using a websocket for pushing events would be the “best” idea.

Discord works this way, the browser/bot sends normal http requests to modify resources and a discord gateway pushes a json object with a string that tells you the event type.

The client only has to send keep-alive packets back to the Websocket server.

Now thankfully, as I discovered this morning in eve-python’s monolithic documentation, Nicola exposed event triggers for both database updates and http requests. Hopefully we’ll be able to route wss through the nginx reverse_proxy no problem. but I wonder about hosting them on the same port.

I wasn’t planning on making a list of events, but duty calls

-discord’s api event types follow the CRUD (create read update delete) operations Multiplied by the objects

right now we have 3 models = [‘ASSET’, ‘TAG’, ‘FOLDERS’]
and we can’t use the Read in this model(I’ll explain why in a just minute) so crud = [‘CREATE’,’UPDATE’,’DELETE’]

3×4 = 12. Easy. Now we build something to write out all these events. Because why not.

>> for x in models:
... for y in crud:
... print('%s_%s_EVENT' % (x,y))

results:

ASSET_CREATE_EVENT
ASSET_UPDATE_EVENT
ASSET_DELETE_EVENT
TAG_CREATE_EVENT
TAG_UPDATE_EVENT
TAG_DELETE_EVENT
FOLDERS_CREATE_EVENT
FOLDERS_UPDATE_EVENT
FOLDERS_DELETE_EVENT

So easy. We can use this to keep a list of events for when documentation is written. Now, onto how discord’s model works. The Discord websocket gateway treats the client as a database and performs CRUD operation on them. It’s easy to see why Read is gone now. The server doesn’t care about the data stored on the clients and clients have to send data to the server through http, treating discord’s api like a database.

I hope you got something out of this cause reading it back it feels a little patronizing.

Leave a Reply

Your email address will not be published. Required fields are marked *