Examples of MultiUserChat


Examples of org.jivesoftware.smackx.muc.MultiUserChat

            // we must add the listener before creating the muc
            final ToContainsFilter toFilter = new ToContainsFilter(endpoint.getParticipant());
            final AndFilter packetFilter = new AndFilter(new PacketTypeFilter(Presence.class), toFilter);
            connection.addPacketListener(this, packetFilter);

            muc = new MultiUserChat(connection, endpoint.resolveRoom(connection));
            muc.addMessageListener(this);
            DiscussionHistory history = new DiscussionHistory();
            history.setMaxChars(0); // we do not want any historical messages

            muc.join(endpoint.getNickname(), null, history, SmackConfiguration.getPacketReplyTimeout());
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

            // we must add the listener before creating the muc
            final ToContainsFilter toFilter = new ToContainsFilter(endpoint.getParticipant());
            final AndFilter packetFilter = new AndFilter(new PacketTypeFilter(Presence.class), toFilter);
            connection.addPacketListener(this, packetFilter);

            muc = new MultiUserChat(connection, endpoint.resolveRoom(connection));
            muc.addMessageListener(this);
            DiscussionHistory history = new DiscussionHistory();
            history.setMaxChars(0); // we do not want any historical messages

            muc.join(endpoint.getNickname(), null, history, SmackConfiguration.getPacketReplyTimeout());
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

            connection = endpoint.createConnection();
        }

        if (chat == null) {
            room = endpoint.resolveRoom(connection);
            chat = new MultiUserChat(connection, room);
            DiscussionHistory history = new DiscussionHistory();
            history.setMaxChars(0); // we do not want any historical messages
            chat.join(endpoint.getNickname(), null, history, SmackConfiguration.getPacketReplyTimeout());
            if (LOG.isInfoEnabled()) {
                LOG.info("Joined room: {} as: {}", room, endpoint.getNickname());
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

    }

    public void startConference(String roomName, String server,
            List<String> users, String reason) {
        // Create a MultiUserChat using a Connection for a room
        MultiUserChat muc = new MultiUserChat(connection, roomName + "@"
                + server);
        PacketListener myListener = new PacketListener() {

            @Override
            public void processPacket(Packet packet) {
                //System.out.println("PacketData:" + packet.toXML());
                if (packet.getClass().toString().equalsIgnoreCase(
                        "class org.jivesoftware.smack.packet.Message")) {
                    Message m = (Message) packet;

                    if (m.getBody() != null) {
                       // System.out.println("Body is " + m.getBody());
                        DelayInformation inf = null;
                        try {
                            inf = (DelayInformation) packet.getExtension(
                                    "x", "jabber:x:delay");


                            String[] username = m.getFrom().split("/");

                            String t[] = username[0].split("@");
                            if (t.length >= 2) {
                                System.out.println("Room:" + t[0] + ",msg:" + m.getBody() + ",User:" + username[1]);
                                sendToConfPage(t[0], m.getBody(), username[1], t[1]);
                            }

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        };
        muc.addMessageListener(myListener);

        PacketListener peopleListener = new PacketListener() {

            @Override
            public void processPacket(Packet packet) {
                //System.out.println("People PacketData:" + packet.toXML());
                if (packet.getClass().toString().equalsIgnoreCase(
                        "class org.jivesoftware.smack.packet.Presence")) {
                    Presence p = (Presence) packet;

                    try {
                        System.out.println("Presence from: " + p.getFrom());
                        System.out.println("Presence :" + p.toString());

                        String[] username = p.getFrom().split("/");
                        String t[] = username[0].split("@");
                        //System.out.println("Room:"+t[0]+",msg:"+m.getBody()+",User:"+username[1]);
                        if (p.toString().equalsIgnoreCase("available")) {
                            sendToConfPage(t[0], "** '" + username[1] + "' joined the room **", "", t[1]);
                        } else if (p.toString().equalsIgnoreCase("unavailable")) {
                            sendToConfPage(t[0], "** '" + username[1] + "' left the room **", "", t[1]);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        muc.addParticipantListener(peopleListener);
        try {
            // Create the room
            //System.out.println(muc);
            muc.create(chatRoom);
            // Send an empty room configuration form which indicates that we
            // want
            // an instant room
            muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
            for (String user : users) {
                muc.invite(user, reason);
            }

            System.out.println("Created Chat Room :" + roomName + " with " + users);
            myChatRooms.add(muc);
        } catch (XMPPException e) {
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

        }

    }

    public void inviteConference(String roomName, List<String> users) {
        MultiUserChat muc = null;
        if (roomName.contains("@")) {
            muc = getChatRoomByName(roomName);
        } else {
            muc = getChatRoomByName(roomName + "@" + conferenceServer);
        }
        System.out.println("invited #:" + users.size());
        if (muc != null) {
            for (String user : users) {
                muc.invite(user, "Invite");
                System.out.println("invited :" + user);
            }
        }
    }
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

            }
        }
    }

    public void joinConference(String room) {
        MultiUserChat muc = new MultiUserChat(connection, room);
        try {
            muc.join(chatRoom);
            myChatRooms.add(muc);
            PacketListener myListener = new PacketListener() {

                @Override
                public void processPacket(Packet packet) {
                    //System.out.println("\nIN:" + chatRoom);
                    //System.out.println("PacketClass:" + packet.getClass());
                    //System.out.println("PacketProperties:"
                    //+ packet.getPropertyNames());
                    //System.out.println("PacketData:" + packet.toXML());
                    if (packet.getClass().toString().equalsIgnoreCase(
                            "class org.jivesoftware.smack.packet.Message")) {
                        Message m = (Message) packet;

                        if (m.getBody() != null) {
                            System.out.println("Body is " + m.getBody());
                            DelayInformation inf = null;
                            try {
                                inf = (DelayInformation) packet.getExtension(
                                        "x", "jabber:x:delay");

                                // get offline message timestamp

                                String[] username = m.getFrom().split("/");

                                String t[] = username[0].split("@");
                                System.out.println("Room:" + t[0] + ",msg:" + m.getBody() + ",User:" + username[1]);
                                sendToConfPage(t[0], m.getBody(), username[1], t[1]);

                            } catch (Exception e) {
                                // log.error(e);
                                e.printStackTrace();
                            }
                        }

                    }
                }
            };
            muc.addMessageListener(myListener);

            PacketListener peopleListener = new PacketListener() {

                @Override
                public void processPacket(Packet packet) {
                    //System.out.println("People PacketData:" + packet.toXML());
                    if (packet.getClass().toString().equalsIgnoreCase(
                            "class org.jivesoftware.smack.packet.Presence")) {
                        Presence p = (Presence) packet;

                        try {
                            System.out.println("Presence from: " + p.getFrom());
                            System.out.println("Presence :" + p.toString());

                            String[] username = p.getFrom().split("/");
                            String t[] = username[0].split("@");
                            //System.out.println("Room:"+t[0]+",msg:"+m.getBody()+",User:"+username[1]);
                            if (p.toString().equalsIgnoreCase("available")) {
                                sendToConfPage(t[0], "** '" + username[1] + "' joined the room **", "", t[1]);
                            } else if (p.toString().equalsIgnoreCase("unavailable")) {
                                sendToConfPage(t[0], "** '" + username[1] + "' left the room **", "", t[1]);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            };
            muc.addParticipantListener(peopleListener);
            System.out.println("Joined Chat Room :" + room);
        } catch (XMPPException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

            // we must add the listener before creating the muc
            final ToContainsFilter toFilter = new ToContainsFilter(endpoint.getParticipant());
            final AndFilter packetFilter = new AndFilter(new PacketTypeFilter(Presence.class), toFilter);
            connection.addPacketListener(this, packetFilter);

            muc = new MultiUserChat(connection, endpoint.resolveRoom(connection));
            muc.addMessageListener(this);
            DiscussionHistory history = new DiscussionHistory();
            history.setMaxChars(0); // we do not want any historical messages

            muc.join(endpoint.getNickname(), null, history, SmackConfiguration.getPacketReplyTimeout());
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

            // we must add the listener before creating the muc
            final ToContainsFilter toFilter = new ToContainsFilter(endpoint.getParticipant());
            final AndFilter packetFilter = new AndFilter(new PacketTypeFilter(Presence.class), toFilter);
            connection.addPacketListener(this, packetFilter);

            muc = new MultiUserChat(connection, endpoint.resolveRoom(connection));
            muc.addMessageListener(this);
            DiscussionHistory history = new DiscussionHistory();
            history.setMaxChars(0); // we do not want any historical messages

            muc.join(endpoint.getNickname(), null, history, SmackConfiguration.getPacketReplyTimeout());
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

    }

    protected synchronized void initializeChat() throws XMPPException {
        if (chat == null) {
            room = endpoint.resolveRoom(connection);
            chat = new MultiUserChat(connection, room);
            DiscussionHistory history = new DiscussionHistory();
            history.setMaxChars(0); // we do not want any historical messages
            chat.join(endpoint.getNickname(), null, history, SmackConfiguration.getPacketReplyTimeout());
            if (LOG.isInfoEnabled()) {
                LOG.info("Joined room: {} as: {}", room, endpoint.getNickname());
View Full Code Here

Examples of org.jivesoftware.smackx.muc.MultiUserChat

            connection = endpoint.createConnection();
        }

        if (chat == null) {
            room = endpoint.resolveRoom(connection);
            chat = new MultiUserChat(connection, room);
            DiscussionHistory history = new DiscussionHistory();
            history.setMaxChars(0); // we do not want any historical messages
            chat.join(endpoint.getNickname(), null, history, SmackConfiguration.getPacketReplyTimeout());
            if (LOG.isInfoEnabled()) {
                LOG.info("Joined room: " + room + " as: " + endpoint.getNickname());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.