Thanks David, but when I do something along the lines of:- def mycall(in): print(in) d = self.connection.boxReceiver.callRemote(Command, a='test') d.addCallBack(mycall)
The print never actually happens. I'm not really sure why, it was one of the first things I tried. I tried the most basic thing, modifying the doMath() example, and mycall only triggers when the reactor stops (even if I run doMath multiple times with delays). On Thu, Oct 29, 2015 at 1:15 PM, David Ripton <drip...@ripton.net> wrote: > On 10/28/2015 02:24 AM, Oon-Ee Ng wrote: >> Working off the example ampserver.py and ampclient.py examples, I >> wanted to build a client which maintains a single connection while >> allowing the passing of messages back and forth. However I'm stuck at >> one of the most basic steps, getting back the result (without >> 'completing' the connection). >> >> The ampclient.py example simply connects, does a callRemote on the >> resulting protocol, and adds callbacks to extract the result from a >> dictionary and print it. The deferred being used in this case is >> produced by connectProtocol. >> >> I'm trying to write a client (inheriting from amp.AMP) which is >> embedded in a kivy GUI, something which is quite possible using the >> _threadedselect reactor. >> >> On connection, I use the connectionMade method to save the 'self' (in >> this case, the client inheriting from amp.AMP) in my kivy app. I can >> then call a function which does a callRemote on this saved client, >> which indeed triggers the server appropriately. >> >> The callRemote returns a deferred (from reading docs online, a remote >> reference). I can't figure out what to do with it, specifically in >> terms of getting the result ('total', when calling Sum from >> ampserver.py). >> >> Assistance much appreciated. > > Basically, callRemote returns a deferred, that you can add callbacks and > errbacks to, which will be called when the remote call succeeds or > fails. On success, the callback will receive an argument equal to the > return value of the remote callable that you called. On failure, the > errback will receive an error argument. > > I have an old GUI (PyGTK, not Kivy) chat over AMP example at > https://github.com/dripton/ampchat that might help you. (Though I think > all of my commands return boring responses.) > > -- > David Ripton drip...@ripton.net > > _______________________________________________ > Twisted-Python mailing list > Twisted-Python@twistedmatrix.com > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python