aboutsummaryrefslogtreecommitdiffstats
path: root/doc/modules/luaevent.core.bufferevent.mdwn
blob: 842ee0634a77cc45254bccacacbc32e9eb154ede (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
----
Functions:

[[toc levels=1]]

## Read/Write/Error Callback:
* Input: `(bufferevent, what)`
	* `bufferevent` - Reference to the bufferevent that raised the callback
	* `what` - What happened:
		* == `EVBUFFER_READ` - Buffer contains at least low-watermark length and no more than high-watermark length
		* == `EVBUFFER_WRITE` - Buffer ready to write to
		* (other) - Error condition
			* May be or-ed/added with `EVBUFFER_READ`/`EVBUFFER_WRITE` to specify where it happened
			* `EVBUFFER_ERROR` - Marks error condition (need to look at 'errno' for error.. not exposed yet)
			* `EVBUFFER_TIMEOUT` - Marks activity timeout
			* `EVBUFFER_EOF` - Marks disconnection/end-of-file condition

## bufferevent.new
* Input: `(fd, read, write, error)`
	* `fd` - File descriptor to watch
	* `read` - (may be nil) - callback to call when data in buffer is above the low watermark
	* `write` - (may be nil) - callback to call when the output buffer contains less data than the low watermark
	* `error` - callback to call when there is an erroneous condition

## bufferevent (__gc)
* Releases the bufferevent
	* Disconnects event buffers since they were owned by the bufferevent object in 'C' land
	* Disconnects all references so that any erroneous callbacks don't cause failures

## bufferevent:get_read
* Obtains the input buffer associated w/ the bufferevent

## bufferevent:get_write
* Obtains the output buffer associated w/ the bufferevent

## bufferevent:set_read_watermarks
* Input: `(low, high)`
	* `low` - Size of buffer at which an event would be fired
	* `high` - Maximum size of buffer to read to

## bufferevent:set_write_watermarks
* Input: `(low, high)`
	* `low` - When buffer is below this, the event will be fired
	* `high` - N/A to libevent, user app may use this

## bufferevent:get_read_watermarks
* Output: `low, high`
* See `set_read_watermarks`

## bufferevent:get_write_watermarks
* Output: `low, high`
* See `set_write_watermarks`

## bufferevent:set_timeouts
* Sets timeouts for the bufferevent's events
* Input: `(read, write)`
	* `read` - Read readiness timeout
	* `write` - Write readiness timeout

## bufferevent:get_timeouts
* Output: `read, write`
* See `set_timeouts`

## bufferevent:enable/disable
* Input: `event flag`
	* `event flag` - `EV_READ`, `EV_WRITE`, or `EV_READ|EV_WRITE`
* Enables/Disables events from being triggered in the next round (some events may get triggered after disable is called)