Responder

From Second Life Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
  • A Responder is a simple abstraction for handling callbacks that have data associated with them.
  • The responder has two essential 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