<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Class: Connection</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" /> <script type="text/javascript"> // <![CDATA[ function popupCode( url ) { window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400") } function toggleCode( id ) { if ( document.getElementById ) elem = document.getElementById( id ); else if ( document.all ) elem = eval( "document.all." + id ); else return false; elemStyle = elem.style; if ( elemStyle.display != "block" ) { elemStyle.display = "block" } else { elemStyle.display = "none" } return true; } // Make codeblocks hidden by default document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" ) // ]]> </script> </head> <body> <div id="classHeader"> <table class="header-table"> <tr class="top-aligned-row"> <td><strong>Class</strong></td> <td class="class-name-in-header">Connection</td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../files/lib/network/connection_rb.html"> lib/network/connection.rb </a> <br /> </td> </tr> <tr class="top-aligned-row"> <td><strong>Parent:</strong></td> <td> <a href="Session.html"> Session </a> </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="diagram"> <map id="map" name="map"> <area shape="RECT" coords="36,113,118,161" href="Connection.html" alt="Connection "> <area shape="RECT" coords="41,17,113,65" href="Session.html" alt="Session "> </map> <img src="../dot/f_25.png" usemap="#map" border=0 alt="TopLevel"> </div> <div id="description"> <p> The connection class maintains a socket connection with a reactor and handles all events dispatched by the reactor. </p> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000250">handle_close</a> <a href="#M000248">handle_input</a> <a href="#M000251">handle_oob</a> <a href="#M000249">handle_output</a> <a href="#M000247">init</a> <a href="#M000246">new</a> <a href="#M000254">query</a> <a href="#M000256">sendmsg</a> <a href="#M000255">set</a> <a href="#M000252">set_initdone</a> <a href="#M000253">update</a> </div> </div> </div> <!-- if includes --> <div id="section"> <div id="attribute-list"> <h3 class="section-bar">Attributes</h3> <div class="name-list"> <table> <tr class="top-aligned-row context-row"> <td class="context-item-name">addr</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">host</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">inbuffer</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"></td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">initdone</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">outbuffer</td> <td class="context-item-value"> [RW] </td> <td class="context-item-desc"></td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">pstack</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">server</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> <tr class="top-aligned-row context-row"> <td class="context-item-name">sockio</td> <td class="context-item-value"> [R] </td> <td class="context-item-desc"></td> </tr> </table> </div> </div> <!-- if method_list --> <div id="methods"> <h3 class="section-bar">Public Class methods</h3> <div id="method-M000246" class="method-detail"> <a name="M000246"></a> <div class="method-heading"> <a href="Connection.src/M000246.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000246.html');return false;"> <span class="method-name">new</span><span class="method-args">(server, sock)</span> </a> </div> <div class="method-description"> <p> Create a new connection object </p> <dl> <dt><tt>server</tt></dt><dd>The reactor this connection is associated with. </dd> <dt><tt>sock</tt></dt><dd>The socket for this connection. </dd> <dt><tt>returns</tt></dt><dd>A connection object. </dd> </dl> </div> </div> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000250" class="method-detail"> <a name="M000250"></a> <div class="method-heading"> <a href="Connection.src/M000250.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000250.html');return false;"> <span class="method-name">handle_close</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> <a href="Connection.html#M000250">handle_close</a> is called to when an close event occurs for this session. </p> </div> </div> <div id="method-M000248" class="method-detail"> <a name="M000248"></a> <div class="method-heading"> <a href="Connection.src/M000248.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000248.html');return false;"> <span class="method-name">handle_input</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> <a href="Connection.html#M000248">handle_input</a> 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. </p> </div> </div> <div id="method-M000251" class="method-detail"> <a name="M000251"></a> <div class="method-heading"> <a href="Connection.src/M000251.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000251.html');return false;"> <span class="method-name">handle_oob</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> <a href="Connection.html#M000251">handle_oob</a> is called when an out of band data event occurs for this session. </p> </div> </div> <div id="method-M000249" class="method-detail"> <a name="M000249"></a> <div class="method-heading"> <a href="Connection.src/M000249.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000249.html');return false;"> <span class="method-name">handle_output</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> <a href="Connection.html#M000249">handle_output</a> is called to order a connection to process any output waiting on its socket. </p> </div> </div> <div id="method-M000247" class="method-detail"> <a name="M000247"></a> <div class="method-heading"> <a href="Connection.src/M000247.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000247.html');return false;"> <span class="method-name">init</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> init is called before using the connection. </p> <dl> <dt><tt>returns</tt></dt><dd>true is connection is properly initialized </dd> </dl> </div> </div> <div id="method-M000254" class="method-detail"> <a name="M000254"></a> <div class="method-heading"> <a href="Connection.src/M000254.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000254.html');return false;"> <span class="method-name">query</span><span class="method-args">(attrib)</span> </a> </div> <div class="method-description"> <dl> <dt><tt>attrib</tt></dt><dd>- A Symbol not handled here is assumed to be a query and </dd> </dl> <pre> 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> </pre> </div> </div> <div id="method-M000256" class="method-detail"> <a name="M000256"></a> <div class="method-heading"> <a href="Connection.src/M000256.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000256.html');return false;"> <span class="method-name">sendmsg</span><span class="method-args">(msg)</span> </a> </div> <div class="method-description"> <p> sendmsg places a message on the <a href="Connection.html">Connection</a>’s output buffer. </p> <dl> <dt><tt>msg</tt></dt><dd>The message, a reference to a buffer </dd> </dl> </div> </div> <div id="method-M000255" class="method-detail"> <a name="M000255"></a> <div class="method-heading"> <a href="Connection.src/M000255.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000255.html');return false;"> <span class="method-name">set</span><span class="method-args">(attrib, val)</span> </a> </div> <div class="method-description"> <dl> <dt>+attrib,val+</dt><dd>- An Array not handled here is assumed to be a set command and </dd> </dl> <pre> its handling is delegated to the ProtocolStack. <pre> client -> us [:color, true] us -> ProtocolStack set(:color, true) </pre> </pre> </div> </div> <div id="method-M000252" class="method-detail"> <a name="M000252"></a> <div class="method-heading"> <a href="Connection.src/M000252.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000252.html');return false;"> <span class="method-name">set_initdone</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> This is called from <a href="TelnetFilter.html">TelnetFilter</a> when we are done with negotiations. The event :initdone wakens observer to begin user activity </p> </div> </div> <div id="method-M000253" class="method-detail"> <a name="M000253"></a> <div class="method-heading"> <a href="Connection.src/M000253.html" target="Code" class="method-signature" onclick="popupCode('Connection.src/M000253.html');return false;"> <span class="method-name">update</span><span class="method-args">(msg)</span> </a> </div> <div class="method-description"> <p> 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. </p> <p> This supports the following: </p> <dl> <dt>:quit</dt><dd>- This symbol message from the client is a request to <pre> close the Connection. It is handled here. </pre> </dd> <dt><a href="String.html">String</a></dt><dd>- A <a href="String.html">String</a> is assumed to be output and placed in our <pre> @outbuffer. </pre> </dd> </dl> </div> </div> </div> </div> <div id="validator-badges"> <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p> </div> </body> </html>