oksirc/irc.cpp

33 lines
844 B
C++

//
// Created by onekopaka on 12/8/18.
//
#include <memory.h>
#include "irc.h"
irc::irc(PRFileDesc* fileDesc, std::string netName, ui* uiInstance) {
this->fd = fileDesc;
this->netName = netName;
this->uiInst = uiInstance;
}
void irc::run() {
PRPollDesc pollDesc;
pollDesc.fd = this->fd;
pollDesc.in_flags = PR_POLL_READ | PR_POLL_WRITE | PR_POLL_EXCEPT;
pollDesc.out_flags = 0;
PRInt32 result = PR_Poll(&pollDesc, 1, PR_INTERVAL_NO_TIMEOUT);
while(result != -1) {
if(result > 0) {
if(pollDesc.out_flags & PR_POLL_READ) {
char* buf = new char[1024];
PRInt32 bytesRead = PR_Read(this->fd, buf, 1024);
uiInst->mainLog->appendPlainText(buf);
}
}
result = PR_Poll(&pollDesc, 1, PR_INTERVAL_NO_TIMEOUT);
}
}