Package chatroom.server.dataclass

Examples of chatroom.server.dataclass.Room


        sb.append(IQ_QUERY_RESPONSE_BEGIN);
        if (jid.isGlobal()) {
            Set<String> rooms = server.getRoomList();
            for (String room : rooms) {
                Jid item = new Jid(room, null);
                Room r = server.getRoom(room);
                sb.append(String.format(IQ_QUERY_RESPONSE_ITEM, item.toString(), server.getRoom(room).getDescription(), r.getUserList().size()));
            }
        } else if (jid.isRoom()) {
            Set<String> users = server.getRoom(jid.getRoom()).getUserList();
            for (String user : users) {
                Jid item = new Jid(jid.getRoom(), user);
View Full Code Here


    @Override
    protected void onPresenceStatus(String from, String to, String status, String show) {
        if (to != null) {
            Jid jid = new Jid(to);
            if (jid.isUser()) {
                Room room = server.getRoom(jid.getRoom());
                User user = server.getUserByConnection(connection);
                if (status != null) {
                    user.setStatus(status);
                }
                user.setShow(show);
                room.broadcastPresence(jid.getName(), null);
            }
        }
    }
View Full Code Here

    @Override
    protected boolean onPresenceAvailable(String from, String to) {
        if (to != null) {
            Jid jid = new Jid(to);
            if (jid.isUser()) {
                Room room = server.getRoom(jid.getRoom());
                User user = server.getUserByConnection(connection);
                int ret = user.joinRoomWithNickname(room, jid.getName());
                if (ret == 1) {
                    for (String other : room.getUserList()) {
                        if (!other.equals(jid.getName())) {
                            user.sendPresence(room, jid.getName(), other, null);
                        }
                    }
                    room.broadcastPresence(jid.getName(), null);
                } else if (ret == 0) {
                    // The nick already existed, send a conflict.
                    user.sendPresenceConflict(room, to);
                    return false;
                }
View Full Code Here

    @Override
    protected void onPresenceUnavailable(String from, String to) {
        if (to != null) {
            Jid jid = new Jid(to);
            if (jid.isUser()) {
                Room room = server.getRoom(jid.getRoom());
                User user = server.getUserByConnection(connection);
                room.broadcastPresence(jid.getName(), "unavailable");
                user.exitRoom(room);
            }
        }
    }
View Full Code Here

    @Override
    protected void onMessageGroupchat(String id, String from, String to, String msg) {
        if (to != null) {
            Jid jid = new Jid(to);
            if (jid.isRoom()) {
                Room room = server.getRoom(jid.getRoom());
                User user = server.getUserByConnection(connection);
                room.broadcast(msg, user.getNicknameByRoom(room));
            }
        }
    }
View Full Code Here

    protected void onMessagePrivate(String id, String from, String to, String msg) {
        if (to != null) {
            Jid jid = new Jid(to);
            if (jid.isUser()) {
                Jid fromJid = new Jid(from);
                Room room = server.getRoom(jid.getRoom());
                User user = room.getUser(jid.getName());
                user.sendMessage(room, fromJid.getName(), null, msg);
            }
        }

        if (from != null) {
            Jid jid = new Jid(from);
            if (jid.isUser()) {
                Jid fromJid = new Jid(to);
                Room room = server.getRoom(jid.getRoom());
                User user = room.getUser(jid.getName());
                user.sendMessage(room, jid.getName(), fromJid.getName(), null, msg);
            }
        }
    }
View Full Code Here

    protected void onIqCardGet(String id, String from, String to) {
        Jid jid = new Jid(to);
        if (jid.isGlobal()) {
            sendIq(id, "result", to, from, String.format(IQ_VCARD, ChatroomServer.getServer().getUserByConnection(connection).getVCard(null)));
        } else if (jid.isUser()) {
            Room room = ChatroomServer.getServer().getRoom(jid.getRoom());
            if (room != null) {
                User user = room.getUser(jid.getName());
                if (user != null) {
                    onSendIqVCard(id, room.getName(), user.getNicknameByRoom(room), user.getVCard(room));
                }
            }
        }
    }
View Full Code Here

    @Override
    protected void onIqPingPort(String id, String from, String to, String port) {
        Jid jid = new Jid(from);
        if (jid.isUser()) {
            Room room = server.getRoom(jid.getRoom());
            int p = -1;
            try {
                p = room.getAudioPort();
            } catch (IOException ex) {
                Logger.getLogger(ServerParser.class.getName()).log(Level.SEVERE, null, ex);
            }
            User user = room.getUser(jid.getName());
            user.sendAudioPort(room, p);
        }
    }
View Full Code Here

    }

    public Room getRoom(String roomName) {
        if (roomList.get(roomName) == null) {
            // TODO: new room handle.
            roomList.put(roomName, new Room(roomName, ""));
        }
        return roomList.get(roomName);
    }
View Full Code Here

TOP

Related Classes of chatroom.server.dataclass.Room

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.