"Callback" design pattern

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

"Callback" design pattern

Stephen Davies-3
Hi,

I've been busy with hooking Squeak to Asterisk via the Asterisk
FastAGI protocol.
I also want to write code to talk to the Asterisk Manager Interface.

In both cases I need to write an interface to allow others to
"register" to hande particular AGI call, or to "register" to hear
about particular AMI events.

I suppose the method of callback will boil down to "call method
#whatever on object anObject", or maybe you could register a block to
be evaluated.

Now I'm sure there must be an established way to do this in Squeak and
I'd like to use it.  Or at least code mine in the "usual style".

So could someone point me at some classes in the system that I should look at?

Thanks,
Steve
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: "Callback" design pattern

Tapple Gao
On Sat, Jun 02, 2007 at 05:59:02PM +0200, Stephen Davies wrote:

> Hi,
>
> I've been busy with hooking Squeak to Asterisk via the Asterisk
> FastAGI protocol.
> I also want to write code to talk to the Asterisk Manager Interface.
>
> In both cases I need to write an interface to allow others to
> "register" to hande particular AGI call, or to "register" to hear
> about particular AMI events.
>
> I suppose the method of callback will boil down to "call method
> #whatever on object anObject", or maybe you could register a block to
> be evaluated.
>
> Now I'm sure there must be an established way to do this in Squeak and
> I'd like to use it.  Or at least code mine in the "usual style".

There are several semi-standard ways to do this in Squeak. The
simplest is the changed-update protocol, defined in Object. The relevant
method categories are "updating" and "dependents access". To use
it, one registers to recieve changes by calling

anObject addDependent: interestedParty.

Then interestedParty>>update: anObject will be called whenever
anObject>>changed is called. There is also a changed: message if
you need more fine-grained events. It is usually used with
Symbols. All of the PluggableMorphs and PluggableViews use this
protocol.

A newer method is the Announcements framework, used by
OmniBrowser. See http://wiki.squeak.org/squeak/5734

I am sure there are more. Object has a few method categories
with events in their names, none of which I recognize. There is
also the class category SystemChangeNotification; this is only
used by the compiler and friends to make sure Browsers are kept
up to date as methods and classes change. Tweak and Croquet also
have their own frameworks I believe, based on asynchronous
message sends.

> So could someone point me at some classes in the system that I should look
> at?
>
> Thanks,
> Steve
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/
Help improve Squeak Documentation: http://wiki.squeak.org/squeak/808
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

RE: "Callback" design pattern

Ron Teitelbaum
In reply to this post by Stephen Davies-3
Hi Stephen,

If you are talking about external callbacks then Squeak doesn't currently
have external callback support, but Andreas Raab created a patch that may
solve your problem.  Check out http://news.squeak.org/2006/12/15/callbacks/.
Also it may be better to post this question to either squeak-dev or the vm
list.  Callbacks are a bit above beginners, and there are some extremely
talented developers on Squeak-dev that may be able to help you solve your
problem.

Happy coding!

Ron Teitelbaum

> -----Original Message-----
> From: [hidden email] [mailto:beginners-
> [hidden email]] On Behalf Of Stephen Davies
> Sent: Saturday, June 02, 2007 11:59 AM
> To: A friendly place to get answers to even the most basic questions
> aboutSqueak.
> Subject: [Newbies] "Callback" design pattern
>
> Hi,
>
> I've been busy with hooking Squeak to Asterisk via the Asterisk
> FastAGI protocol.
> I also want to write code to talk to the Asterisk Manager Interface.
>
> In both cases I need to write an interface to allow others to
> "register" to hande particular AGI call, or to "register" to hear
> about particular AMI events.
>
> I suppose the method of callback will boil down to "call method
> #whatever on object anObject", or maybe you could register a block to
> be evaluated.
>
> Now I'm sure there must be an established way to do this in Squeak and
> I'd like to use it.  Or at least code mine in the "usual style".
>
> So could someone point me at some classes in the system that I should look
> at?
>
> Thanks,
> Steve
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners