python-astm icon indicating copy to clipboard operation
python-astm copied to clipboard

How does server is supposed to send data ?

Open QM-OSchwab opened this issue 5 years ago • 3 comments

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

QM-OSchwab avatar Mar 10 '20 10:03 QM-OSchwab

Did you solve this problem?

idkCpp avatar Feb 11 '21 15:02 idkCpp

Has anyone solved this issue?

RamilMurzaev avatar Dec 20 '22 09:12 RamilMurzaev

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.

tsibley avatar Dec 20 '22 20:12 tsibley