ircbot/Testcode/Client/ClientManagerTest.php

56 lines
1.5 KiB
PHP

<?php
$clientManager = new \JPT\SocketFramework\Client\ClientManager();
$clientManager->registerClientDispatcherByProtocol("irc", "\JPT\IrcClient\IrcClientDispatcher");
$clientManager->registerClientDispatcherByProtocol("jpt_control", "\JPT\IrcClient\BotClientDispatcher");
$freenode = $clientManager->createTcpConnection("freenode", "irc");
$clientManager->attachConfig(array(
"nick" => "Pb42|test",
"userident" => "lalala",
"channels" => array("##available")
), $freenode);
$freenode->connect("irc.freenode.net", 6667);
$freenode->setReconnect(TRUE);
/*
$euirc = $clientManager->createTcpConnection("euirc", "irc");
$clientManager->attachConfig(array(
"nick" => "Pb42",
"userident" => "Serena",
"channels" => array()
), $euirc);
$euirc->connect("irc.euirc.net", 6667);
$euirc->setReconnect(TRUE);
*/
/*$osuIRC = $clientManager->createTcpConnection("osuIRC", "irc");
$clientManager->attachConfig(array(
"nick" => "Pb42",
"userident" => "Serena",
"channels" => array("#osu", "#german")
), $osuIRC);
$osuIRC->connect("irc.ppy.sh", 6667);
$osuIRC->setReconnect(TRUE);*/
/*$config_eloxoph = array(
"nick" => "Frischmilch",
"userident" => "olefolol",
"channels" => array("#eloxoph")
);
$eloxoph = $clientManager->createTcpConnection("eloxoph", "irc");
$clientManager->attachConfig($config_eloxoph, $eloxoph);
$eloxoph->connect("irc.eloxoph.com", 6667);*/
$srv = $clientManager->createTcpConnection("srv", "jpt_control");
$srv->bind("localhost", 7777);
$srv->listen();
while($clientManager->countActiveConnections() > 0) {
$clientManager->work();
}
?>