| Class | Connection |
| In: |
lib/network/connection.rb
|
| Parent: | Session |
The connection class maintains a socket connection with a reactor and handles all events dispatched by the reactor.
| addr | [R] | |
| host | [R] | |
| inbuffer | [RW] | |
| initdone | [R] | |
| outbuffer | [RW] | |
| pstack | [R] | |
| server | [R] | |
| sockio | [R] |
Create a new connection object
handle_input is called to order a connection to process any input waiting on its socket. Input is parsed into lines based on the occurance of the CRLF terminator and pushed into a buffer which is a list of lines. The buffer expands dynamically as input is processed. Input that has yet to see a CRLF terminator is left in the connection’s inbuffer.
handle_output is called to order a connection to process any output waiting on its socket.
its handling is delegated to the ProtocolStack, the result
of which is a pair immediately sent back to as a message
to the client.
<pre>
client -> us
:echo
us -> ProtocolStack
query(:echo)
ProtocolStack -> us
[:echo, true]
us -> client
[:echo, true]
</pre>
sendmsg places a message on the Connection’s output buffer.
its handling is delegated to the ProtocolStack.
<pre>
client -> us
[:color, true]
us -> ProtocolStack
set(:color, true)
</pre>
This is called from TelnetFilter when we are done with negotiations. The event :initdone wakens observer to begin user activity
Update will be called when the object the connection is observing wants to notify us of a change in state or new message. When a new connection is accepted in acceptor that connection is passed to the observer of the acceptor which allows the client to attach an observer to the connection and make the connection an observer of that object. We need to keep both sides interest in each other limited to a narrow but flexible interface to prevent tight coupling.
This supports the following: