<?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: Reactor</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">Reactor</td> </tr> <tr class="top-aligned-row"> <td><strong>In:</strong></td> <td> <a href="../files/lib/network/reactor_rb.html"> lib/network/reactor.rb </a> <br /> </td> </tr> <tr class="top-aligned-row"> <td><strong>Parent:</strong></td> <td> Object </td> </tr> </table> </div> <!-- banner header --> <div id="bodyContent"> <div id="contextContent"> <div id="diagram"> <map id="map" name="map"> <area shape="RECT" coords="32,17,104,65" href="Reactor.html" alt="Reactor "> </map> <img src="../dot/f_28.png" usemap="#map" border=0 alt="TopLevel"> </div> <div id="description"> <p> The <a href="Reactor.html">Reactor</a> class defines a representation of a multiplexer based on a non-blocking select() server. </p> <p> The network design is based on the Mesh project NetworkService code which was translated almost directly from C++, warts and all, which in turn is based on Schmidt’s <a href="Acceptor.html">Acceptor</a>/<a href="Connector.html">Connector</a>/<a href="Reactor.html">Reactor</a> patterns which may be found at <a href="http://citeseer.ist.psu.edu/schmidt97acceptor.html">citeseer.ist.psu.edu/schmidt97acceptor.html</a> for an idea of how all these classes are supposed to interelate. </p> </div> </div> <div id="method-list"> <h3 class="section-bar">Methods</h3> <div class="name-list"> <a href="#M000037">new</a> <a href="#M000040">poll</a> <a href="#M000041">register</a> <a href="#M000038">start</a> <a href="#M000039">stop</a> <a href="#M000042">unregister</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">port</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">service_filters</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">service_io</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">service_negotiation</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">service_type</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-M000037" class="method-detail"> <a name="M000037"></a> <div class="method-heading"> <a href="Reactor.src/M000037.html" target="Code" class="method-signature" onclick="popupCode('Reactor.src/M000037.html');return false;"> <span class="method-name">new</span><span class="method-args">(service_port, service_type, service_io, service_negotiation, service_filters, address=nil)</span> </a> </div> <div class="method-description"> <p> Constructor for <a href="Reactor.html">Reactor</a> </p> <dl> <dt><tt>service_port</tt></dt><dd>The port the server will listen on or client will connect to. </dd> <dt><tt>service_type</tt></dt><dd>The type of service (:server or :client) </dd> <dt><tt>service_io</tt></dt><dd>The service io handler (:sockio, :lineio, or :packetio) </dd> <dt><tt>service_negotiation</tt></dt><dd>An array of telnet options the service will try to negotiate </dd> </dl> <pre> Valid options are :sga, :echo, :naws, :ttype, :zmp (negotiate default) :binary </pre> <dl> <dt><tt>service_filters</tt></dt><dd>An array of io filters the service will use. </dd> </dl> <pre> Valid options are :filter - attach dummy filter :debugfilter - attach debug filter (default) :telnetfilter - attach telnet filter (default) :colorfilter - attach color filter (default) :terminalfilter - attach terminal filter </pre> <dl> <dt><tt>address</tt></dt><dd>Optional address for outgoing connection. </dd> </dl> </div> </div> <h3 class="section-bar">Public Instance methods</h3> <div id="method-M000040" class="method-detail"> <a name="M000040"></a> <div class="method-heading"> <a href="Reactor.src/M000040.html" target="Code" class="method-signature" onclick="popupCode('Reactor.src/M000040.html');return false;"> <span class="method-name">poll</span><span class="method-args">(tm_out)</span> </a> </div> <div class="method-description"> <p> poll starts the <a href="Reactor.html">Reactor</a> running to process incoming connection, input and output requests. It also executes commands from input requests. </p> <dl> <dt>+tm_out*</dt><dd>time to poll in seconds </dd> </dl> </div> </div> <div id="method-M000041" class="method-detail"> <a name="M000041"></a> <div class="method-heading"> <a href="Reactor.src/M000041.html" target="Code" class="method-signature" onclick="popupCode('Reactor.src/M000041.html');return false;"> <span class="method-name">register</span><span class="method-args">(session)</span> </a> </div> <div class="method-description"> <p> register adds a session to the registry [<tt>session</tt>] </p> </div> </div> <div id="method-M000038" class="method-detail"> <a name="M000038"></a> <div class="method-heading"> <a href="Reactor.src/M000038.html" target="Code" class="method-signature" onclick="popupCode('Reactor.src/M000038.html');return false;"> <span class="method-name">start</span><span class="method-args">(engine)</span> </a> </div> <div class="method-description"> <p> Start initializes the reactor and gets it ready to accept incoming connections. </p> <dl> <dt><tt>engine</tt></dt><dd>The client engine that will be observing the acceptor. </dd> <dt><tt>return</tt>‘</dt><dd>true if server boots correctly, false if an error occurs. </dd> </dl> </div> </div> <div id="method-M000039" class="method-detail"> <a name="M000039"></a> <div class="method-heading"> <a href="Reactor.src/M000039.html" target="Code" class="method-signature" onclick="popupCode('Reactor.src/M000039.html');return false;"> <span class="method-name">stop</span><span class="method-args">()</span> </a> </div> <div class="method-description"> <p> stop requests each of the connections to disconnect in the server’s user list, deletes the connections, and erases them from the user list. It then closes its own listening port. </p> </div> </div> <div id="method-M000042" class="method-detail"> <a name="M000042"></a> <div class="method-heading"> <a href="Reactor.src/M000042.html" target="Code" class="method-signature" onclick="popupCode('Reactor.src/M000042.html');return false;"> <span class="method-name">unregister</span><span class="method-args">(session)</span> </a> </div> <div class="method-description"> <p> unregister removes a session from the registry [<tt>session</tt>] </p> </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>