There is no such option (at least at present).
Also, the docs really should all be up to date now for all public
methods (the events pages need some clean up though). There's also a
wiki page on internals that covers some functions in more depth
(assuming I outlined them fully accurately--but I should have at least
discussed all possible eventualities evident in the functions where not
covered in the API now). But the API docs should, I think, all be
comprehensive and valid.
best wishes,
Brett
On 12/18/2008 2:17 PM, sylver wrote:
> Thanks for the code. It works :D
>
> The way the above code works is when a stream is created (tries to
> login) an alert box will appear, correct? are there any other states
> for this type of event?
>
> The wiki @ http://github.com/bard/sameplace/wikis/api-event seems to
> be missing the states:
> [...snip...]
> Event: connector
>
> Generated when incoming or outgoing XML streams are open. Properties:
>
> * event – “connector”
> * direction – “in” or “out”
> * state -
> [...snip...]
>
>
These are detailed at http://github.com/bard/sameplace/wikis/api-channel
. Feel free to update the api-event page, if you like :)
My patch aims to also add:
1) Addresses potential stream-level errors: "sasl-error", "tls-error",
"session-error". (Authentication is a type of SASL error.)
2) Stream features: "features".
3) Changing the 'active' state to return (as with a proposed 'bound'
state) the JID bound by the server (e.g., if the server decides to
change or add a resource, as the spec allows it to do, you'd have a way
to get it).
> Is there any way of achieving this:
>
> begin
> xmpp.up(account, function(){ connectSuccess(); }); //assuming
> account is defined
> var tmr = setTimeout("failToConnect()", 15000); // 15secs timout
>
> function failToConnect(){ alert("Sorry...try again"); }
>
> function connectSuccess(){
> alert("Connected!");
> clearTimeout(tmr);
> }
> end
>
There is nothing in the API to specifically control timeouts, but that
doesn't mean you couldn't use one.
In the xmpp4moz source, I see there are only two one-shot 3-second
timeouts (at the beginning of an outgoing stream and after starting
TLS), timeouts which simply lead to one additional reconnect attempt.
(There is also another 30 second timer which continually repeats after a
session has been established, simply sending whitespace to the server to
keep the connection alive.)
FYI, in debugging, I was able to do the following to trace the
connection events as they took place for me:
var prompts =
Cc['@mozilla.org/embedcomp/prompt-service;1'].getService(Ci.nsIPromptService);
var temp = '';
channel.on (
{event : 'connector'},
function (el) {
temp += el.state+' : ';
prompts.alert(null, 'Session Error', temp);
}
);
The last alert here gave me:
connecting : wait-stream : stream-open : features :
auth-waiting-result : wait-stream : stream-open : features :
binding-resource : bound : requesting-session : idle :
(note that features and bound are my own states, not currently in
xmpp4moz, but it may give further indication of what is going on)
Maybe you could come up with some timeout that considered the current
state and the apparent fact that only one reconnect attempt is made
(e.g., I imagine "connecting" might not show up a third time).
Or maybe you could also simply periodically check whether the connection
is still up with XMPP.isUp()?
I'm sorry but I don't quite understand this fully either, but maybe the
above can help you figure something out, if Massimiliano doesn't have
anything to suggest...
best wishes,
Brett