About the RemoteEventTarget interface

The removeEventSource() method is provided to remove one instance of a source (one matching URL) per invocation, but no way is defined to know whether other instances are yet listed, or if the operation succeeded. Maybe such method could return a boolean value telling whether the operation was successful, so that, i.e., all matching URLs could be removed at once in a simple iteration calling the method until it returns "false". Maybe a "remove all" method could be considered too.

I guess a single RemoteEventTarget can list several time the same remote source to take advantage of more than one connection (maybe non-http) to fetch different resources and/or to ask for different server-side computations in parallel; however, it might be helpful to define either a mechanism to remove a precise source (i.e. passing an index or the alike, not just the URL) instead of removing a source on a "per enter position" basis (that is, the first encountered is removed, as could be thought) or a precise choice algorithm (i.e., skipping an "active" URL), since without neither a precise targeting nor a precise algorithm a somewhat user agent could remove the wrong url upon request, and so closing for instance a connection with a pending get operation: one of a RemoteEventTarget message event handlers could receive an "end event" and try and close its connection, but the implementation, by mistake, could remove a source URL used by another handler waiting for a response, or the method could be invoked from a piece of code outside any handler, and so the choice might become more difficult. Otherwise, an algorithm should be defined to switch the communications from a closed source to another still active.

According to the previous hint, let me suggest the following:
- a streamed event should be associate to a numerical index representing either the relative position (i.e. indicating it's the Nth occurrence) or the absolute position of the source URL in the RemoteEventTarget list of event sources; for this purpose, the last event id attribute should be considered unreliable;

- a removeEventSource() method variant is provided accepting the index as a second parameter;

- when the removeEventSource is invoked without the index argument (i.e. to iteratively remove all occurrences), the following algorithm is applied:
1) if the URL resolution fails return false and abort these steps;
2) pick the first occurrence of src argument in the list of event sources, if any;
3) if no occurrence has been found return false and abort these steps;
4) if a "remove source as possible task" or a "remove source immediately task" has been tailed for src, stop execution and return true;
5) queue a "remove source as possible task" and return true;

- when the removeEventSource is invoked with the index argument follow the previous steps but change step 2) and 3) as follow: 2) pick the source occurrence in the list of event sources corresponding to the index argument and compare it with src argument;
3) if comparison fails return false and abort these steps;

a "remove source as possible task" is a task delegated to remove the source URL from the list of event sources and to close the related connection as soon as any pending event is completely received and dispatched to every listening handler and no message has been post to the remote server (otherwise wait for the response event); a "remove source immediately task" is a task performing the same operation but without waiting for pending events: as soon as the task is executed, the event source is eliminated.

- a couple of removeEventSourceNow() methods is provided with the same characteristics of the previous, but queueing a "remove source immediately task".

- if needed, an appropriate task source is provided.

Regards, Alex


--
Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP 
autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Tom Raider Anniversary ora sul tuo cellulare! Entra in azione!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8277&d=16-12

Reply via email to