kxepal / python-astm

Python implementation of ASTM E1381/1394 data protocol.
http://python-astm.readthedocs.org/en/latest/
Other
52 stars 47 forks source link

How does server is supposed to send data ? #8

Open QM-OSchwab opened 4 years ago

QM-OSchwab commented 4 years ago

Hello,

Using code in #1 , I was able to send data to server, so far so good. But how does the server is supposed to send data to client ? I looked at the doc and examples but I don't understand how it is meant to be done.

Thx

idkCpp commented 3 years ago

Did you solve this problem?

RamilMurzaev commented 1 year ago

Has anyone solved this issue?

tsibley commented 1 year ago

It's been a while since I was using this, but I believe you can call self.push(data) or self.push_from_producer(producer) from inside one of the on_* methods in your records dispatcher. Those methods come from astm.asynclib.AsyncChat via astm.protocol.ASTMProtocol via astm.server.RequestHandler, which is called by astm.server.Server.handle_accept().

https://github.com/kxepal/python-astm/blob/606a77407e59c2f2dd12d65a7b2d2e3c141ad8d9/astm/asynclib.py#L858-L874

You could also probably call the underlying self.send(data) method available via astm.asynclib.Dispatcher, but that's lower-level and you'll lose some of the protocol handling that's otherwise done for you.