Start attempting to actually do IRC
This commit is contained in:
parent
65d123ce2c
commit
a66071288a
5 changed files with 75 additions and 5 deletions
33
irc.cpp
Normal file
33
irc.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Created by onekopaka on 12/8/18.
|
||||
//
|
||||
|
||||
#include <memory.h>
|
||||
#include "irc.h"
|
||||
|
||||
irc::irc(PRFileDesc* fileDesc, char* netName, ui* uiInstance) {
|
||||
this->fd = fileDesc;
|
||||
this->netName = strdup(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);
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue