Perhaps it is more of a question of how to implement it on the browser rather than how to implement it in PHP.

For quite some time we have had a CTI function running on a browser. You know the sort of thing - a call centre agent sits staring at their screen waiting for an incoming call. When it arrives (i.e. their phone rings) they answer it and at the same time the browser pops up with the details of the customer on the end of the phone.

So far we have only managed to get this working consistently by having the browser polling the server for the incoming call using an xmlHttpRequest. It either returns "nothing there" or it returns the page containing the customer details of the incoming call. However, since it is a polling technique, you get the inevitable timing issues where the agent sometimes gets a pregnant pause before the screen pops up.

It would be much better if we could write a listener that runs on the browser, so that the server can ping the details back to the browser and get it to instantly respond consistently. So far though, we haven't managed it. I think it might be possible to create a socket client in Adobe Flex that can establish a connection with the server and then wait for a response - perhaps periodically timing out to allow other events to fire. We haven't had time to try it, and I don't know how well it would work. The main issue appears to be with the inability to do true multithreading. The other issue would be the fact that it would not be good to start tying up lots of Apache CGI threads with permanent connections to the browser - which perhaps indicates the need for a different socket server, or a different Apache instance, which in turn raises the problem of cross-domain request handling.

If anyone has cracked this sort of issue I would be anxious to see some details.

-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Nathan Andelin
Sent: 30 November 2010 12:44
To: Web Enabling the AS400 / iSeries
Subject: [WEB400] What is Event Driven Programming, its uses, & how to implement it in PHP?

That is a question that came up recently in a PHP group on Linkedin. I thought
it might also be worth discussing here, too.

Some years ago I became acquainted with a rather robust system for managing
credit unions where the entire UI was implemented through a single command line
prompt, like a Unix or DOS shell. Quite literally, the only two events that the
server would respond to were the Enter and Escape keys. Interaction with the
server would begin by entering a short action code, which would generally
trigger a dialog to enter data into a database, perform transactions, and so
forth, one input line at a time.

Perhaps surprisingly, users liked it, and became productive with it, but
contrast that type of UI with an HTML page that may be filled with any number of
visual and input capable elements simultaneously, and using
element.addEventListener() or element.attachEvent() to register a potentially
broad range of keyboard and mouse event handlers for any number UI element

I suppose you could carry the comparison (contrast) even further by using AJAX
to subscribe to a network service which may be "listening" for events on a
network, and notify each client of it. A good use case might be a moderated chat
service. It might be helpful to update each user's screen whenever a participant
on the network enters or leaves the chat service. Maybe you want their name
begin flashing when they begin typing. Every client should be notified the
moment any one of them enters a new message.

I'm not sure how to implement something that in PHP. I assume it can be done
because Facebook chat works something like that. Using a tool like Fiddler, you
can see the browser performing an asynchronous request that waits for up to
something like 2 minutes, for the server respond. I assume the server in turn is
waiting on a queue of sorts. But I'm not aware of the implementation details on
the server, beyond configuring the HTTP server to allow persistent connections.

Contrast network listening, vs network polling. Polling from the client at
regular intervals consumes more bandwidth and other resources, and yet is not
quite as responsive as listening on a queue.


This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives

NOTICE: The information in this electronic mail transmission is intended by CoralTree Systems Ltd for the use of the named individuals or entity to which it is directed and may contain information that is privileged or otherwise confidential. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email or by telephone, so that the sender's address records can be corrected.


CoralTree Systems Limited
25 Barnes Wallis Road
Segensworth East, Fareham
PO15 5TT

Company Registration Number 5021022.
Registered Office:
12-14 Carlton Place
Southampton, UK
SO15 2EA
VAT Registration Number 834 1020 74.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].