Package org.schwering.irc.lib

Examples of org.schwering.irc.lib.IRCConnection


            handleNickInUse();
        }
    }

    private void handleNickInUse() {
        IRCConnection connection = component.getIRCConnection(configuration);
        String nick = connection.getNick() + "-";

        // hackish but working approach to prevent an endless loop. Abort after 4 nick attempts.
        if (nick.endsWith("----")) {
            LOG.error("Unable to set nick: " + nick + " disconnecting");
        } else {
            LOG.warn("Unable to set nick: " + nick + " Retrying with " + nick + "-");
            connection.doNick(nick);
            // if the nick failure was doing startup channels weren't joined. So join
            // the channels now. It's a no-op if the channels are already joined.
            joinChannels();
        }
    }
View Full Code Here


    public void joinChannel(IrcChannel channel) {
        if (channel == null) {
            return;
        }

        IRCConnection connection = component.getIRCConnection(configuration);

        String chn = channel.getName();
        String key = channel.getKey();

        if (ObjectHelper.isNotEmpty(key)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Joining: {} using {} with secret key", channel, connection.getClass().getName());
            }
            connection.doJoin(chn, key);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Joining: {} using {}", channel, connection.getClass().getName());
            }
            connection.doJoin(chn);
        }
    }
View Full Code Here

        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating Connection to " + configuration.getHostname() + " destination: " + configuration.getTarget()
                    + " nick: " + configuration.getNickname() + " user: " + configuration.getUsername());
        }

        final IRCConnection conn = new IRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(),
                                                     configuration.getNickname(), configuration.getUsername(), configuration.getRealname());
        conn.setEncoding("UTF-8");
        conn.setColors(configuration.isColors());
        conn.setPong(true);

        try {
            conn.connect();
        } catch (Exception e) {
            throw new RuntimeCamelException(e);
        }
        return conn;
    }
View Full Code Here

    public void setConfiguration(IrcConfiguration configuration) {
        this.configuration = configuration;
    }

    public synchronized IRCConnection getIRCConnection(IrcConfiguration configuration) {
        final IRCConnection connection;
        if (connectionCache.containsKey(configuration.getCacheKey())) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Returning Cached Connection to " + configuration.getHostname() + " " + configuration.getTarget());
            }
            connection = connectionCache.get(configuration.getCacheKey());
View Full Code Here

    protected IRCConnection createConnection(IrcConfiguration configuration) {
        LOG.debug("Creating Connection to " + configuration.getHostname() + " destination: " + configuration.getTarget() + " nick: " + configuration.getNickname() + " user: "
                  + configuration.getUsername());

        final IRCConnection conn = new IRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(), configuration.getNickname(), configuration.getUsername(),
                                                     configuration.getRealname());
        conn.setEncoding("UTF-8");
        // conn.setDaemon(true);
        conn.setColors(configuration.isColors());
        conn.setPong(true);

        try {
            conn.connect();
        } catch (Exception e) {
            LOG.error("Failed to connect: " + e, e);

            // TODO use checked exceptions?
            throw new RuntimeCamelException(e);
View Full Code Here

    public void dispose()
    {
        // cleanup connections
        for ( String key : hostConnections.keySet() )
        {
            IRCConnection connection = hostConnections.get( key );
            if ( connection.isConnected() )
            {
                connection.doQuit( "Continuum shutting down" );
                connection.close();
            }
        }

    }
View Full Code Here

    private IRCConnection getIRConnection( String host, int port, String password, String nick, String alternateNick,
                                           String userName, String realName, String channel, boolean ssl )
        throws IOException
    {
        String key = getConnectionKey( host, port, nick, alternateNick );
        IRCConnection conn = hostConnections.get( key );
        if ( conn != null )
        {
            checkConnection( conn, key );
            return conn;
        }

        if ( !ssl )
        {
            conn = new IRCConnection( host, new int[]{port}, password, nick, userName, realName );
        }
        else
        {
            conn = new SSLIRCConnection( host, new int[]{port}, password, nick, userName, realName );
            ( (SSLIRCConnection) conn ).addTrustManager( new SSLDefaultTrustManager() );
        }

        conn.addIRCEventListener( new Listener( conn, nick, alternateNick ) );
        checkConnection( conn, key );
        checkChannel( conn, key, channel );
        hostConnections.put( key, conn );
        return conn;
    }
View Full Code Here

        boolean isSsl = Boolean.parseBoolean( configuration.get( "ssl" ) );

        try
        {
            IRCConnection ircConnection = getIRConnection( host, port, password, nickName, alternateNickName, userName,
                                                           fullName, channel, isSsl );
            ircConnection.doPrivmsg( channel, generateMessage( project, build ) );
        }
        catch ( IOException e )
        {
            throw new NotificationException( "Exception while checkConnection to irc ." + host, e );
        }
View Full Code Here

    public void setConfiguration(IrcConfiguration configuration) {
        this.configuration = configuration;
    }

    public synchronized IRCConnection getIRCConnection(IrcConfiguration configuration) {
        final IRCConnection connection;
        if (connectionCache.containsKey(configuration.getCacheKey())) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Returning Cached Connection to " + configuration.getHostname() + " " + configuration.getTarget());
            }
            connection = connectionCache.get(configuration.getCacheKey());
View Full Code Here

    protected IRCConnection createConnection(IrcConfiguration configuration) {
        LOG.debug("Creating Connection to " + configuration.getHostname() + " destination: " + configuration.getTarget() + " nick: " + configuration.getNickname() + " user: "
                  + configuration.getUsername());

        final IRCConnection conn = new IRCConnection(configuration.getHostname(), configuration.getPorts(), configuration.getPassword(), configuration.getNickname(), configuration.getUsername(),
                                                     configuration.getRealname());
        conn.setEncoding("UTF-8");
        // conn.setDaemon(true);
        conn.setColors(configuration.isColors());
        conn.setPong(true);

        try {
            conn.connect();
        } catch (Exception e) {
            LOG.error("Failed to connect: " + e, e);

            // TODO use checked exceptions?
            throw new RuntimeCamelException(e);
View Full Code Here

TOP

Related Classes of org.schwering.irc.lib.IRCConnection

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.