Log.debug("Parsing a packet : " + buffer.toString());
HashMap<String, Object> rawPacket = MSIMParser.parse(buffer.toString());
if (rawPacket.containsKey("bm")) {
PacketType type = PacketType.eval((String) rawPacket.get("bm"));
if (type.equals(PacketType.INSTANT_MESSAGE)) {
InstantMessage message = new InstantMessage();
message.setFrom((String) rawPacket.get("f"));
message.setBody((String) rawPacket.get("msg"));
invokeMessageListener(message);
}
else if (type.equals(PacketType.STATUS_MESSAGE)) {
String statusPcs[] = rawPacket.get("msg").toString().split("\\|");
int statusType = Integer.valueOf(statusPcs[2]);
String statusMsg = statusPcs[4];
StatusMessage message = new StatusMessage();
message.setFrom((String) rawPacket.get("f"));
message.setStatusMessage(statusMsg);
message.setStatusCode(statusType);
invokeMessageListener(message);
}
else if (type.equals(PacketType.ACTION_MESSAGE)) {
ActionMessage message = new ActionMessage();
message.setFrom((String) rawPacket.get("f"));
message.setAction((String) rawPacket.get("msg"));
invokeMessageListener(message);
}