Responder

From Second Life Wiki
Revision as of 14:20, 9 February 2007 by Steve Linden (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  • A Responder is a simple abstraction for handling callbacks that have data associated with them.
  • The responder has two essencial properties:
    • It is ref counted so that it gets destroyed when both the responder and the respondee are finished with it
    • It has a virtual 'completed' function that is called by the responder and implemented by the respondee
  • Simple example:
class LLResponder : public LLThreadSafeRefCount
{
public:
	virtual ~LLResponder();
	virtual void completed(bool success) = 0;
};

class MyResponder : public LLResponder; // contains private data and overrides completed()

make_a_request("foo", new MyResponder(mydata)}; // when the request completes, MyResponder::completed() will get called