• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IRCConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.schwering.irc.lib.IRCConnection的典型用法代码示例。如果您正苦于以下问题:Java IRCConnection类的具体用法?Java IRCConnection怎么用?Java IRCConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IRCConnection类属于org.schwering.irc.lib包,在下文中一共展示了IRCConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: start

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Override
public void start(Map<String, String> props) {
    queue = new LinkedBlockingQueue<>();
    host = props.get(IRCFeedConnector.IRC_HOST_CONFIG);
    port = Integer.parseInt(props.get(IRCFeedConnector.IRC_PORT_CONFIG));
    channels = props.get(IRCFeedConnector.IRC_CHANNELS_CONFIG).split(",");
    topic = props.get(IRCFeedConnector.TOPIC_CONFIG);


    String nick = "kafka-connect-irc-" + Math.abs(new Random().nextInt());
    log.info("Starting irc feed task " + nick + ", channels " + props.get(IRCFeedConnector.IRC_CHANNELS_CONFIG));
    this.conn = new IRCConnection(host, new int[]{port}, "", nick, nick, nick);
    this.conn.addIRCEventListener(new IRCMessageListener());
    this.conn.setEncoding("UTF-8");
    this.conn.setPong(true);
    this.conn.setColors(false);
    try {
        this.conn.connect();
    } catch (IOException e) {
        throw new RuntimeException("Unable to connect to " + host + ":" + port + ".", e);
    }
    for (String channel : channels) {
        this.conn.send("JOIN " + channel);
    }

}
 
开发者ID:amient,项目名称:hello-kafka-streams,代码行数:27,代码来源:IRCFeedTask.java


示例2: open

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
public void open() {
    queue = new LinkedBlockingQueue<>();

    String nick = "kafka-connect-irc-" + Math.abs(new Random().nextInt());
    log.info("Starting irc feed task " + nick + ", channels " + String.join(",", channels));
    this.conn = new IRCConnection(host, new int[]{port}, "", nick, nick, nick);
    this.conn.addIRCEventListener(new IRCMessageListener());
    this.conn.setEncoding("UTF-8");
    this.conn.setPong(true);
    this.conn.setColors(false);
    try {
        this.conn.connect();
    } catch (IOException e) {
        throw new RuntimeException("Unable to connect to " + host + ":" + port + ".", e);
    }
    for (String channel : channels) {
        this.conn.send("JOIN " + channel);
    }
}
 
开发者ID:amient,项目名称:hello-streams,代码行数:20,代码来源:IRCSource.java


示例3: joinChannel

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
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);
    }
    if (configuration.isNamesOnJoin()) {
        connection.doNames(chn);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:IrcEndpoint.java


示例4: doSetup

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Before
public void doSetup() {
    connection = mock(IRCConnection.class);
    endpoint = mock(IrcEndpoint.class);
    configuration = mock(IrcConfiguration.class);
    listener = mock(IRCEventAdapter.class);
    exchange = mock(Exchange.class);
    message = mock(Message.class);

    List<IrcChannel> channels = new ArrayList<IrcChannel>();
    channels.add(new IrcChannel("#chan1", null));
    channels.add(new IrcChannel("#chan2", "chan2key"));

    when(configuration.getChannels()).thenReturn(channels);
    when(endpoint.getConfiguration()).thenReturn(configuration);

    producer = new IrcProducer(endpoint, connection);
    producer.setListener(listener);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:IrcProducerTest.java


示例5: doSetup

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Before
public void doSetup() {
    connection = mock(IRCConnection.class);
    endpoint = mock(IrcEndpoint.class);
    processor = mock(Processor.class);
    configuration = mock(IrcConfiguration.class);
    listener = mock(IRCEventAdapter.class);

    List<IrcChannel> channels = new ArrayList<IrcChannel>();
    channels.add(new IrcChannel("#chan1", null));
    channels.add(new IrcChannel("#chan2", "chan2key"));

    when(configuration.getChannels()).thenReturn(channels);
    when(endpoint.getConfiguration()).thenReturn(configuration);

    consumer = new IrcConsumer(endpoint, processor, connection);
    consumer.setListener(listener);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:IrcConsumerTest.java


示例6: doSetup

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Before
public void doSetup() {
    component = mock(IrcComponent.class);
    configuration = mock(IrcConfiguration.class);
    connection = mock(IRCConnection.class);

    List<IrcChannel> channels = new ArrayList<IrcChannel>();
    channels.add(new IrcChannel("#chan1", null));
    channels.add(new IrcChannel("#chan2", "chan2key"));

    when(configuration.getChannels()).thenReturn(channels);
    when(configuration.findChannel("#chan1")).thenReturn(channels.get(0));
    when(configuration.findChannel("#chan2")).thenReturn(channels.get(1));
    when(component.getIRCConnection(configuration)).thenReturn(connection);

    endpoint = new IrcEndpoint("foo", component, configuration);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:IrcEndpointTest.java


示例7: createConnection

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Override
protected IRCConnection createConnection(IrcConfiguration configuration) {
  IRCConnection connection = super.createConnection(configuration);
  listener = new BotecoIrcEventListener(connection, configuration, repository, bus);
  connection.addIRCEventListener(listener);
  return connection;
}
 
开发者ID:devnull-tools,项目名称:boteco,代码行数:8,代码来源:BotecoIrcComponent.java


示例8: BotecoIrcEventListener

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
/**
 * Creates a new listener using the given parameters
 *
 * @param connection    the irc connection to execute operations
 * @param configuration the configuration to get the bot information
 * @param repository    the channel repository for auto join feature
 * @param bus           the message bus to broadcast events
 */
public BotecoIrcEventListener(IRCConnection connection,
                              IrcConfiguration configuration,
                              IrcChannelsRepository repository,
                              EventBus bus) {
  this.connection = connection;
  this.configuration = configuration;
  this.repository = repository;
  this.bus = bus;
}
 
开发者ID:devnull-tools,项目名称:boteco,代码行数:18,代码来源:BotecoIrcEventListener.java


示例9: WikipediaEditEventIrcStream

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
WikipediaEditEventIrcStream(String host, int port) {
	final String nick = "flink-bot-" + UUID.randomUUID().toString();
	this.conn = new IRCConnection(host, new int[] { port}, "", nick, nick, nick);
	conn.addIRCEventListener(new WikipediaIrcChannelListener(edits));
	conn.setEncoding("UTF-8");
	conn.setPong(true);
	conn.setColors(false);
	conn.setDaemon(true);
	conn.setName("WikipediaEditEventIrcStreamThread");
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:WikipediaEditEventIrcStream.java


示例10: handleNickInUse

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
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();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:IrcEndpoint.java


示例11: getIRCConnection

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
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.getNickname());
        }
        connection = connectionCache.get(configuration.getCacheKey());
    } else {
        connection = createConnection(configuration);
        connectionCache.put(configuration.getCacheKey(), connection);
    }
    return connection;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:IrcComponent.java


示例12: closeConnection

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
public void closeConnection(String key, IRCConnection connection) {
    try {
        connection.doQuit();
        connection.close();
    } catch (Exception e) {
        LOG.warn("Error during closing connection.", e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:IrcComponent.java


示例13: doStop

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Override
protected void doStop() throws Exception {
    // lets use a copy so we can clear the connections eagerly in case of exceptions
    Map<String, IRCConnection> map = new HashMap<String, IRCConnection>(connectionCache);
    connectionCache.clear();
    for (Map.Entry<String, IRCConnection> entry : map.entrySet()) {
        closeConnection(entry.getKey(), entry.getValue());
    }
    super.doStop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:IrcComponent.java


示例14: main

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    List<IrcChannel> channels = new ArrayList<IrcChannel>();
    channels.add(new IrcChannel("camel-test", null));
    final IrcConfiguration config = new IrcConfiguration("irc.codehaus.org", "camel-rc", "Camel IRC Component", channels);

    final IRCConnection conn = new IRCConnection(config.getHostname(), config.getPorts(), config.getPassword(), config.getNickname(), config.getUsername(), config.getRealname());

    conn.addIRCEventListener(new CodehausIRCEventAdapter());
    conn.setEncoding("UTF-8");
    // conn.setDaemon(true);
    conn.setColors(false);
    conn.setPong(true);

    try {
        conn.connect();
    } catch (IOException e) {
        e.printStackTrace();
    }
    // while (!conn.isConnected()) {
    // Thread.sleep(1000);
    // LOG.info("Sleeping");
    // }
    LOG.info("Connected");
    // conn.send("/JOIN #camel-test");

    // LOG.info("Joining Channel: " + config.getTarget());

    for (IrcChannel channel : config.getChannels()) {
        conn.doJoin(channel.getName());
    }

    conn.doPrivmsg("#camel-test", "hi!");
    Thread.sleep(Integer.MAX_VALUE);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:35,代码来源:CodehausIrcChat.java


示例15: WikipediaFeed

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
public WikipediaFeed(String host, int port) {
  this.channelListeners = new HashMap<String, Set<WikipediaFeedListener>>();
  this.host = host;
  this.port = port;
  this.nick = "samza-bot-" + Math.abs(random.nextInt());
  this.conn = new IRCConnection(host, new int[] { port }, "", nick, nick, nick);
  this.conn.addIRCEventListener(new WikipediaFeedIrcListener());
  this.conn.setEncoding("UTF-8");
  this.conn.setPong(true);
  this.conn.setColors(false);
}
 
开发者ID:yoloanalytics,项目名称:bigdata-swamp,代码行数:12,代码来源:WikipediaFeed.java


示例16: IRCChatAPITask

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
public IRCChatAPITask(Context context, IRCConnection connection,
		AsyncResponseListener callback,
		AsyncJobNotifierAccessors notifierAccessors) {
	super();
	this.connection = connection;
	this.callback = callback;
	this.unitTestNotifierAccessors = notifierAccessors;
}
 
开发者ID:cherrymathew,项目名称:evend,代码行数:9,代码来源:IRCChatAPITask.java


示例17: doInBackground

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Override
protected IRCConnection doInBackground(String... params) {
	if (connection != null) {
		try {
			connection.connect();
		} catch (IOException e) {
			DebugHelper.ShowMessage.d(e.getMessage());
		}
	}
	return connection;
}
 
开发者ID:cherrymathew,项目名称:evend,代码行数:12,代码来源:IRCChatAPITask.java


示例18: onPostExecute

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Override
protected void onPostExecute(IRCConnection result) {
	super.onPostExecute(result);

	callback.postAsyncTaskCallback(result);

	if (unitTestNotifierAccessors != null
			&& unitTestNotifierAccessors.getUnitTestNotifier() != null) {
		unitTestNotifierAccessors.getUnitTestNotifier().executionDone();
	}
}
 
开发者ID:cherrymathew,项目名称:evend,代码行数:12,代码来源:IRCChatAPITask.java


示例19: initializeIRCConnection

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
private void initializeIRCConnection() {
	connection = new IRCConnection(serverIRC, startPort, endPort, "",
			nickNameIRC, nickNameIRC, nickNameIRC);
	connection.addIRCEventListener((IRCEventListener) this);
	connection.setEncoding("UTF-8");
	connection.setPong(true);
	connection.setDaemon(false);
	connection.setColors(false);
}
 
开发者ID:cherrymathew,项目名称:evend,代码行数:10,代码来源:ChatActivity.java


示例20: postAsyncTaskCallback

import org.schwering.irc.lib.IRCConnection; //导入依赖的package包/类
@Override
public void postAsyncTaskCallback(IRCConnection connection) {
	this.connection = connection;

	if (this.connection != null && this.connection.isConnected()) {
		this.connection.doJoin(channelIRC);
	}
}
 
开发者ID:cherrymathew,项目名称:evend,代码行数:9,代码来源:ChatActivity.java



注:本文中的org.schwering.irc.lib.IRCConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ElGamalPrivateKeyParameters类代码示例发布时间:2022-05-22
下一篇:
Java SQLExprTableSource类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap