Ejemplo n.º 1
0
void LibEventMain::readfn(bufferevent *bev, void *arg) {
    EventHandler *p = (EventHandler *) arg;
    INFO_OUT("Readfn %s:\n", (p ? p->getDescription() : "None"));
    evbuffer *input, *output;

    size_t n;
    int i;

    input = bufferevent_get_input(bev);

    char buffer[max_buff];

//
//	char *data = evbuffer_readln(input, &n, EVBUFFER_EOL_LF);
//	p->process(data, n, true);
//	free(data);
    if ((n = evbuffer_remove(input, buffer, sizeof(buffer))) > 0) {
        p->process(buffer, n, !n);
    }

    // Todo: What happens to the remaining buffer that is less than max_buff
}