diff options
author | Treeki <treeki@gmail.com> | 2014-01-21 01:01:43 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2014-01-21 01:01:43 +0100 |
commit | 26ad55851febe624145ac807dbf59376ba669eaf (patch) | |
tree | 4746daf7d106a18f17f9d96966800b04b6d148bc /ircserver.cpp | |
parent | 8b32f42df825a03284f5c340499394b93dc1a65d (diff) | |
download | bounce4-26ad55851febe624145ac807dbf59376ba669eaf.tar.gz bounce4-26ad55851febe624145ac807dbf59376ba669eaf.zip |
refactoring: add event handling functions to the Server/IRCServer interface
Diffstat (limited to '')
-rw-r--r-- | ircserver.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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); +} |