is.skip(12);
// is.readDWord(); // IP Address (defunct)
// is.readDWord(); // Account number (defunct)
// is.readDWord(); // Registration authority (defunct)
String username = is.readNTString();
ByteArray data = null;
StatString statstr = null;
switch(eid) {
case EID_SHOWUSER:
case EID_JOIN:
statstr = is.readStatString();
break;
case EID_USERFLAGS:
// Sometimes USERFLAGS contains a statstring; sometimes
// it doesn't
statstr = is.readStatString();
if(statstr.toString().length() == 0)
statstr = null;
break;
default:
data = new ByteArray(is.readNTBytes());
break;
}
BNetUser user = null;
switch(eid) {
case EID_SHOWUSER:
case EID_USERFLAGS:
case EID_JOIN:
case EID_LEAVE:
case EID_TALK:
case EID_EMOTE:
case EID_WHISPERSENT:
case EID_WHISPER:
switch(productID) {
case D2DV:
case D2XP:
int asterisk = username.indexOf('*');
if(asterisk >= 0)
username = username.substring(asterisk+1);
break;
}
// Get a BNetUser object for the user
if(myUser.equals(username))
user = myUser;
else
user = getCreateBNetUser(username, myUser);
// Set the flags, ping, statstr
user.setFlags(flags);
user.setPing(ping);
if(statstr != null)
user.setStatString(statstr);
break;
}
switch(eid) {
case EID_SHOWUSER:
case EID_USERFLAGS:
dispatchChannelUser(user);
break;
case EID_JOIN:
dispatchChannelJoin(user);
break;
case EID_LEAVE:
dispatchChannelLeave(user);
break;
case EID_TALK:
dispatchRecieveChat(user, data);
break;
case EID_BROADCAST:
dispatchRecieveBroadcast(username, flags, data.toString());
break;
case EID_EMOTE:
dispatchRecieveEmote(user, data.toString());
break;
case EID_INFO:
dispatchRecieveServerInfo(data.toString());
break;
case EID_ERROR:
dispatchRecieveServerError(data.toString());
break;
case EID_CHANNEL:
// Don't clear the queue if we're connecting for the first time or rejoining
String newChannel = data.toString();
if((channelName != null) && !channelName.equals(newChannel))
clearQueue();
channelName = newChannel;
dispatchJoinedChannel(newChannel, flags);
dispatchTitleChanged();
if(botnet != null)
botnet.sendStatusUpdate();
break;
case EID_WHISPERSENT:
dispatchWhisperSent(user, data.toString());
break;
case EID_WHISPER:
dispatchWhisperRecieved(user, data.toString());
break;
case EID_CHANNELDOESNOTEXIST:
dispatchRecieveError("Channel does not exist; creating");
sendJoinChannel2(data.toString());
break;
case EID_CHANNELRESTRICTED:
long timeSinceNormalJoin = timeNow - lastNormalJoin;
if((lastNormalJoin != 0) && (timeSinceNormalJoin < 5000)) {
dispatchRecieveError("Channel is restricted; forcing entry");
sendJoinChannel2(data.toString());
} else {
dispatchRecieveError("Channel " + data.toString() + " is restricted");
}
break;
case EID_CHANNELFULL:
dispatchRecieveError("Channel " + data.toString() + " is full");
break;
default:
dispatchRecieveError("Unknown SID_CHATEVENT " + eid + ": " + data.toString());
break;
}
break;
}