powered by Jive Software

Anonymous change nickname

Hi guys,

I’'ve got a little problem getting a nickname change to work with XIFF. Using anonymous login, when I change the nickname on the Room instance it sends out a userDeparture event, though the user stays connected, but can no longer send any messages to the room.

Probably missing something obvious, any thoughts? The settings should be alright, using WildFire, the room allows users to change nickname.

Thanks!

Peter

I’'ve found this same problem in my project, and I have a fix.

The nickname update event appears to kill the current connection after sending the nick change request (as it must, “userx” would need to leave the room in order to “become” “usery”). There is then a return packet, containing the new nick approval.

The event in Room.as which is designed to handle this approval, expects a ‘‘oldnick/newnick’’ structure in presence.from; however, anonymous from fields are constructed as ‘‘roomname/oldnick/newnick’’. The use of a slash as delimiter for both data breaks the handler.

The fix is to detect for the possibility of a third element in the from field ‘’/’’ split, and to add a Room.join() event to the event handler itself.

This has not been tested extensively with non-anonymous users - I’‘ve tested groupchat between 3 anons on XIFF and a logged in user on Pidgin, and it doesn’'t break

A better fix might only detect for the third split-element if XMPPConnection._useAnonymousLogin is true.

The file I’‘m using is from the XIFF 2.0.0 beta 4 package; I’'ve included relevant comment lines in case my line numbers are off. Leading tabs have been removed.

Current, Room.as:662

// If the presence has our pending nickname, nickname change went through

if( presence.from.split( “/” )[1] == pendingNickname ) {

myNickname = pendingNickname;

pendingNickname = null;

}

Fix, Room.as:662

// If the presence has our pending nickname, nickname change went through

if ( ( presence.from.split( “/” )[1] == pendingNickname ) || ( presence.from.split( “/” )[2] && ( presence.from.split( “/” )[2] == pendingNickname ) ) ) {

myNickname = pendingNickname;

pendingNickname = null;

this.join();

}

Sample XML/trace output from my app:

SENT:

buttonHandler_changeToNick_1

:s: click
SENT:
RECEIVED:
RECEIVED:
SENT:
RECEIVED:
RECEIVED: –
buttonHandler_changeToNick_2
:s: click

SENT:
RECEIVED:
RECEIVED:
SENT:
RECEIVED:
RECEIVED: –
buttonHandler_changeToNick_1
:s: click

SENT:

buttonHandler_changeToNick_0

:s: click

SENT: