englercj / node-esl

FreeSWITCH ESL implementation for Node.js; implements the full Event Socket Library specified in: http://wiki.freeswitch.org/wiki/Esl
http://englercj.github.com/node-esl/
MIT License
170 stars 111 forks source link

Any way to deserialise serialised object back to Event #67

Open royalpinto opened 6 years ago

royalpinto commented 6 years ago
Any way to deserialise serialised object back to Event ?

This would be useful with clustering (one use case) in which master process listens to the events, serialises and evenly distributes to the workers. When worker receives these events from the master process, if there is any way to convert back serialised object back to Event, it can use all the methods associated with it.

englercj commented 6 years ago

To make there be a clean API for that it would require refactoring the Parser to have the two concerns it has currently (socket listening and stream parsing/buffering) separated. So there would be something that listens to the socket and buffers, then something that parses the buffered data into an Event object. You could then use that second thing.

Other options include having the master send events to slaves using a socket connection that you setup the parser to listen to so it just parses things coming over the wire, or just copy-paste the parsing code into your own thing that you can use for custom stuff. Currently there is no clean way of doing what you want.