doc/modules/luaevent.core.bufferevent.mdwn

1
----
2
Functions:
3
 
4
[[toc levels=1]]
5
 
6
## Read/Write/Error Callback:
7
* Input: `(bufferevent, what)`
8
	* `bufferevent` - Reference to the bufferevent that raised the callback
9
	* `what` - What happened:
10
		* == `EVBUFFER_READ` - Buffer contains at least low-watermark length and no more than high-watermark length
11
		* == `EVBUFFER_WRITE` - Buffer ready to write to
12
		* (other) - Error condition
13
			* May be or-ed/added with `EVBUFFER_READ`/`EVBUFFER_WRITE` to specify where it happened
14
			* `EVBUFFER_ERROR` - Marks error condition (need to look at 'errno' for error.. not exposed yet)
15
			* `EVBUFFER_TIMEOUT` - Marks activity timeout
16
			* `EVBUFFER_EOF` - Marks disconnection/end-of-file condition
17
 
18
## bufferevent.new
19
* Input: `(fd, read, write, error)`
20
	* `fd` - File descriptor to watch
21
	* `read` - (may be nil) - callback to call when data in buffer is above the low watermark
22
	* `write` - (may be nil) - callback to call when the output buffer contains less data than the low watermark
23
	* `error` - callback to call when there is an erroneous condition
24
 
25
## bufferevent (__gc)
26
* Releases the bufferevent
27
	* Disconnects event buffers since they were owned by the bufferevent object in 'C' land
28
	* Disconnects all references so that any erroneous callbacks don't cause failures
29
 
30
## bufferevent:get_read
31
* Obtains the input buffer associated w/ the bufferevent
32
 
33
## bufferevent:get_write
34
* Obtains the output buffer associated w/ the bufferevent
35
 
36
## bufferevent:set_read_watermarks
37
* Input: `(low, high)`
38
	* `low` - Size of buffer at which an event would be fired
39
	* `high` - Maximum size of buffer to read to
40
 
41
## bufferevent:set_write_watermarks
42
* Input: `(low, high)`
43
	* `low` - When buffer is below this, the event will be fired
44
	* `high` - N/A to libevent, user app may use this
45
 
46
## bufferevent:set_timeouts
47
* Sets timeouts for the bufferevent's events
48
* Input: `(read, write)`
49
	* `read` - Read readiness timeout
50
	* `write` - Write readiness timeout
51
 
52
## bufferevent:enable/disable
53
* Input: `event flag`
54
	* `event flag` - `EV_READ`, `EV_WRITE`, or `EV_READ|EV_WRITE`
55
* Enables/Disables events from being triggered in the next round (some events may get triggered after disable is called)