Comet in Aida/Web
Comet, or so called Reverse Ajax is an updating some element of your web page when some event occurs on the server side, not the client one.
In Aida this is easy achievable by deferring a response to periodic Ajax update of some element until a server event occurs. And to signal that event, you can use Announcements event framework (currently available on Squeak and VisualWorks)
Comet is supported in Aida as a pattern because there is no special additional code for Comet in Aida, you are just using usual periodic updater, but server delays the answer to this Ajax request until some interesting event happen to be worth refreshing the page.
Basically you do:
1. prepare and element for a content to be Comet updatable, in some method, say #liveContent.
2. let you Ajax periodically update that element, (period can be as short as possible, we delay the answer anyway), say in view #live of MyApp:
e add: (self liveContent updateEverySeconds: 1).
So far so good, no let we prepare our reverse Ajax by deferring the response. Let we now break that delay and respond immediately when some event is sent via Announcements framework
3. let we prepare our defer code at the start of #liveContent
self session lastRequest isAjaxRequest ifTrue:
e := WebElement new.
"show your content here"
| count change |
count := 1. change := false.
when: OurAnnouncement do: [:ann | change := true] for: self.
[change not and: [count < 1000]] whileTrue:
[(Delay forSeconds: 1) wait.
count := count + 1].
self observee unsubscribe: self
OurAnnouncement is a subclass of Announcement for our case. Above code will respond in a less that 1 second after an event occurs. If you want faster response, change Delay code accordingly. Also this method can be possibly done better...
4. Domain object (observee) must now send OurAnnouncement on event to trigger sending above response and refresh the web page. Look at Announcements docs for that. Probably you'll in myDomainObject just do:
self announce: OurAnnouncement.
More about Announcements can be found on Vassili Bykov blog