Package com.brewtab.irc.messages

Examples of com.brewtab.irc.messages.Message


     * complete
     *
     * @return true if joined successfully, false otherwise
     */
    public boolean join() {
        Message joinMessage = new Message(MessageType.JOIN, this.channelName);
        List<Message> response;

        try {
            response = connection.request(
                MessageFilters.message(MessageType.RPL_NAMREPLY, null, "=", channelName),
View Full Code Here


     * (non-Javadoc)
     * @see com.brewtab.irc.impl.IRCChannel#part(java.lang.String)
     */
    @Override
    public void part(String reason) {
        Message partMessage = new Message(MessageType.PART, this.channelName, reason);
        this.client.getConnection().send(partMessage);
        this.joined = new CountDownLatch(1);
    }
View Full Code Here

     * (non-Javadoc)
     * @see com.brewtab.irc.impl.IRCChannel#write(java.lang.String)
     */
    @Override
    public void write(String text) {
        Message privMessage = new Message(MessageType.PRIVMSG, this.channelName, text);
        this.client.getConnection().send(privMessage);
    }
View Full Code Here

     */
    @Override
    public void writeMultiple(String... strings) {
        Message[] privMessages = new Message[strings.length];
        for (int i = 0; i < strings.length; i++) {
            privMessages[i] = new Message(MessageType.PRIVMSG, this.channelName, strings[i]);
        }
        this.client.getConnection().send(privMessages);
    }
View Full Code Here

     * Makes a NAMES request to the server for this channel. Store the result
     * replacing any existing names list. The list can be retrieved with
     * IRCChannel#getNames
     */
    public void refreshNames() {
        Message namesMessage = new Message(MessageType.NAMES, this.channelName);
        List<Message> response;

        try {
            response = connection.request(
                MessageFilters.message(MessageType.RPL_NAMREPLY, null, "=", channelName),
View Full Code Here

        this.connection.addMessageListener(
            MessageFilters.message(MessageType.PING, (String) null),
            new MessageListener() {
                @Override
                public void onMessage(Message message) {
                    connection.send(new Message(MessageType.PONG, message.getArgs()));
                }
            });
    }
View Full Code Here

    }

    void registerConnection(String nick, String username, String hostname, String realName, String password) {
        log.debug("registering connection");

        Message nickMessage = new Message(MessageType.NICK, nick);
        Message userMessage = new Message(MessageType.USER, username, hostname, hostname, realName);

        if (password != null) {
            /* Send a PASS message first */
            connection.send(new Message(MessageType.PASS, password));
        }

        Message response;

        try {
            response = connection.request(
                null,
                MessageFilters.any(
                    MessageFilters.message(MessageType.RPL_ENDOFMOTD),
                    MessageFilters.message(MessageType.RPL_LUSERME),
                    MessageFilters.message(MessageType.RPL_LUSERCHANNELS),
                    MessageFilters.message(MessageType.RPL_LUSERCLIENT),
                    MessageFilters.message(MessageType.RPL_LUSEROP),
                    MessageFilters.message(MessageType.RPL_LUSERUNKNOWN),
                    MessageFilters.message(MessageType.ERR_NICKNAMEINUSE)),
                nickMessage, userMessage).get(0);
        } catch (InterruptedException e) {
            throw new ConnectionException("Interrupted while awaiting connection registration response");
        }

        switch (response.getType()) {
        case ERR_NICKNAMEINUSE:
            throw new NickNameInUseException();
        default:
            log.debug("connection registered");
            break;
View Full Code Here

    public void quit(String reason) {
        if (!connected) {
            throw new NotConnectedException();
        }

        Message quit = new Message(MessageType.QUIT, reason);
        ChannelFuture future = connection.send(quit);

        /* Wait for message to be sent and then close the underlying connection */
        future.addListener(new ChannelFutureListener() {
            @Override
View Full Code Here

    public void sendMessage(User user, String message) {
        if (!connected) {
            throw new NotConnectedException();
        }

        connection.send(new Message(MessageType.PRIVMSG, user.getNick(), message));
    }
View Full Code Here

    @Override
    public void setNick(String nick) {
        if (connected) {
            try {
                Message response = connection.request(
                    null,
                    MessageFilters.any(
                        MessageFilters.message(MessageType.ERR_NICKNAMEINUSE),
                        MessageFilters.message(MessageType.NICK, nick)),
                    new Message(MessageType.NICK, nick)).get(0);

                if (response.getType() == MessageType.ERR_NICKNAMEINUSE) {
                    throw new NickNameInUseException();
                }
            } catch (InterruptedException e) {
                throw new RuntimeException("request interrupted");
            }
View Full Code Here

TOP

Related Classes of com.brewtab.irc.messages.Message

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.