Package net.sf.jmyspaceiml.packet

Examples of net.sf.jmyspaceiml.packet.InstantMessage


        assertTrue(connection.isConnected());

        // 6221 is the userid of "tom" who seems to be a type of bot that
        // responds with a "woo!" when you send him a message
        InstantMessage message = new InstantMessage();
        message.setTo("6221");
        message.setBody("boo");

        connection.sendPacket(message);

        try {
            Thread.sleep(5000);
View Full Code Here


        assertEquals(0, connection.getMessageListeners().size());

        connection.addMessageListener(listener);
        assertEquals(1, connection.getMessageListeners().size());

        InstantMessage message = new InstantMessage();
        message.setTo("jack");
        message.setBody("boo");
        connection.invokeMessageListener(message);

        connection.removeMessageListener(listener);
        assertEquals(0, connection.getMessageListeners().size());
    }
View Full Code Here

        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);
            }
            else {
                Log.debug("Unsupported buddy message type: " + type);
            }
        }
        else if (rawPacket.containsKey("ka")) {
            // Keepalive status packet.
            Log.debug("Received keepalive packet.");
        }
        else if (rawPacket.containsKey("persistr")) {
            // Persistent roster packet.
            contactManager.parseContactListPacket(rawPacket);
        }
        else if (rawPacket.containsKey("error")) {
            // Error message
            ErrorMessage message = new ErrorMessage();
            message.setErrorMessage((String) rawPacket.get("errmsg"));
            message.setIsFatal(rawPacket.containsKey("fatal"));
            invokeMessageListener(message);
        }
        else {
            Log.debug("Unsupported packet type: " + rawPacket);
        }
View Full Code Here

TOP

Related Classes of net.sf.jmyspaceiml.packet.InstantMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.