gifsockets-server
gifsockets-server copied to clipboard
Break out gifsockets as middleware
It would be nice to use gifsockets on any server. This repo should be more of a demo than something to depend on.
First thought is function that returns an object of middlewares:
gifsocketsMiddleware({
width: 20,
height: 10
});
// Returns
{
openImage: function (req, res) {},
writeFrame: function (req, res) {}
}
It would make sense for writeTextToImage to be a middleware that comes before writeFrame, we just need to figure out how to do this sans raw-body parsing (probably make that a requisite for previous middlewares -- req.body || req.pixels)
Technically, we can have another layer which is a class that has methods for adding streams (kind of like pipe), writing new frames, and closing streams.
The addition of streams would return an id which allows us to close a specific stream or all of them.
gifsockets has been broken out as a mediator. We should implement it and still consider doing a middleware
https://github.com/twolfson/gifsockets