con_sse_write(agooCon c) {
    agooRes	res = agoo_con_res_pop(c);
    agooText	message = agoo_res_message_peek(res);
    ssize_t	cnt;

    if (NULL == message) {
	agoo_res_destroy(res);

	return false;
    }
    c->timeout = dtime() + CON_TIMEOUT *2;
    if (0 == c->wcnt) {
	agooText	t;

	if (agoo_push_cat.on) {
	    agoo_log_cat(&agoo_push_cat, "%llu: %s %p", (unsigned long long)c->id, message->text, (void*)res);
	}
	t = agoo_sse_expand(message);
	if (t != message) {
	    agoo_res_message_push(res, t);
	    message = t;
	}
    }
    if (0 > (cnt = send(c->sock, message->text + c->wcnt, message->len - c->wcnt, 0))) {
	char	msg[1024];
	int	len;

	if (EAGAIN == errno) {
	    return true;
	}
	len = snprintf(msg, sizeof(msg) - 1, "Socket error @ %llu.", (unsigned long long)c->id);
	push_error(c->up, msg, len);
	agoo_log_cat(&agoo_error_cat, "Socket error @ %llu.", (unsigned long long)c->id);

	return false;
    }
    c->wcnt += cnt;
    if (c->wcnt == message->len) { // finished
	agooText	next = agoo_res_message_next(res);

	c->wcnt = 0;
	if (NULL == next) {
	    bool	done = res->close;

	    agoo_res_destroy(res);

	    return !done;
	}
    }
    agoo_con_res_prepend(c, res);

    return true;
}
con_sse_write(agooCon c) {
    agooRes	res = agoo_con_res_pop(c);
    agooText	message = agoo_res_message_peek(res);
    ssize_t	cnt;

    if (NULL == message) {
	agoo_res_destroy(res);

	return false;
    }
    c->timeout = dtime() + CON_TIMEOUT *2;
    if (0 == c->wcnt) {
	agooText	t;

	if (agoo_push_cat.on) {
	    agoo_log_cat(&agoo_push_cat, "%llu: %s %p", (unsigned long long)c->id, message->text, (void*)res);
	}
	t = agoo_sse_expand(message);
	if (t != message) {
	    agoo_res_message_push(res, t);
	    message = t;
	}
    }
    if (0 > (cnt = send(c->sock, message->text + c->wcnt, message->len - c->wcnt, 0))) {
	char	msg[1024];
	int	len;

	if (EAGAIN == errno) {
	    return true;
	}
	len = snprintf(msg, sizeof(msg) - 1, "Socket error @ %llu.", (unsigned long long)c->id);
	push_error(c->up, msg, len);
	agoo_log_cat(&agoo_error_cat, "Socket error @ %llu.", (unsigned long long)c->id);

	return false;
    }
    c->wcnt += cnt;
    if (c->wcnt == message->len) {  
	agooText	next = agoo_res_message_next(res);

	c->wcnt = 0;
	if (NULL == next) {
	    bool	done = res->close;

	    agoo_res_destroy(res);

	    return !done;
	}
    }
    agoo_con_res_prepend(c, res);

    return true;
}