Module | EventMachine::Protocols::LineText2
In: | lib/protocols/linetext2.rb

In the grand, time-honored tradition of re-inventing the wheel, we offer here YET ANOTHER protocol that handles line-oriented data with interspersed binary text. This one trades away some of the performance optimizations of EventMachine::Protocols::LineAndTextProtocol in order to get better correctness with regard to binary text blocks that can switch back to line mode. It also permits the line-delimiter to change in midstream. This was originally written to support Stomp.

### Methods

receive_binary_data receive_data receive_end_of_binary_data receive_line set_binary_mode set_delimiter set_line_mode set_text_mode unbind

### Constants

MaxLineLength | = | 16*1024 |  | TODO! We‘re not enforcing the limits on header lengths and text-lengths. When we get around to that, call receive_error if the user defined it, otherwise throw exceptions.
MaxBinaryLength | = | 32*1024*1024

### Public Instance methods

receive_binary_data(data)

Stub. Should be subclassed by user code.

receive_data(data)
receive_end_of_binary_data()

Stub. Should be subclassed by user code. This is called when transitioning internally from text mode back to line mode. Useful when client code doesn‘t want to keep track of how much data it‘s received.

receive_line(ln)

Stub. Should be subclassed by user code.

set_binary_mode(size=nil)

Alias for set_text_mode, added for back-compatibility with LineAndTextProtocol.

set_delimiter(delim)
set_line_mode(data="")

Called internally but also exposed to user code, for the case in which processing of binary data creates a need to transition back to line mode. We support an optional parameter to "throw back" some data, which might be an umprocessed chunk of the transmitted binary data, or something else entirely.

set_text_mode(size=nil)
unbind()

In case of a dropped connection, we‘ll send a partial buffer to user code when in sized text mode. User overrides of receive_binary_data need to be aware that they may get a short buffer.

[Validate]