From 26ad55851febe624145ac807dbf59376ba669eaf Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 21 Jan 2014 01:01:43 +0100 Subject: refactoring: add event handling functions to the Server/IRCServer interface --- ircserver.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'ircserver.cpp') diff --git a/ircserver.cpp b/ircserver.cpp index 94456dc..8ccdbb9 100644 --- a/ircserver.cpp +++ b/ircserver.cpp @@ -7,3 +7,31 @@ IRCServer::IRCServer(Bouncer *_bouncer) : Server(_bouncer) { void IRCServer::connect() { Server::connect(config.hostname, config.port, config.useTls); } + + +void IRCServer::connectedEvent() { + printf("[IRCServer:%p] connectedEvent\n", this); + + char buf[2048]; + + if (strlen(config.password) > 0) { + sprintf(buf, "PASS %s", config.password); + sendLine(buf); + } + + sprintf(buf, "USER %s 0 * :%s\r\nNICK %s", + config.username, config.realname, config.nickname); + sendLine(buf); +} +void IRCServer::disconnectedEvent() { + printf("[IRCServer:%p] disconnectedEvent\n", this); +} +void IRCServer::lineReceivedEvent(char *line, int size) { + printf("[%d] { %s }\n", size, line); + + Buffer pkt; + pkt.writeStr(line, size); + for (int i = 0; i < bouncer->clientCount; i++) + if (bouncer->clients[i]->authState == Client::AS_AUTHED) + bouncer->clients[i]->sendPacket(Packet::B2C_STATUS, pkt); +} -- cgit v1.2.3