listener.rb

Path: lib/mues/listener.rb  (CVS)
Last Update: Sat Aug 18 22:54:10 -0700 2007

This file contains the MUES::Listener class: An abstract base class for "listener" objects. Instances of concrete derivatives of this class encapsulate the functionality of opening a "listening" IO object and then joining incoming connections on that IO object with an instance of MUES::IOEventFilter that is designed to service it.

Instances of this class‘s derivatives are usually constructed by a MUES::Config::ListenersSection object.

Concrete derivatives of this class will probably be interested in providing implementations of one or more of the following operations:

createOutputFilter( reactorObject )
Called when the listener‘s IO object indicates it is readable, this method is responsbible for doing any preparation work (eg., calling accept on the socket, etc.), and returning an appropriate MUES::IOEventFilter object. The reactorObject parameter is the Engine‘s IO::Reactor object, which the filter can use to drive its own IO, perhaps through a MUES::ReactorProxy object.
releaseOutputFilter( filter )
Called after a filter created by this listener indicates that its peer has disconnected or that it has an error condition, this method is responsible for returning any resources the filter has held to the system. The filter argument is the disconnecting MUES::IOEventFilter object.

Synopsis

  require 'mues/reactorproxy'
  require 'mues/ioeventfilters'

  class MySocketListener < MUES::Listener

      def createOutputFilter( reactor )
          clientSocket = self.io.accept
          proxy = MUES::ReactorProxy::new( reactor, clientSocket )
          return MUES::MyOutputFilter::new( clientSocket, reactorProxy )
      end

      def releaseOutputFilter( filter )
          # no-op
      end

  end

Subversion ID

$Id: listener.rb 1215 2004-06-14 06:02:09Z deveiant $

Authors

  • Michael Granger <ged@FaerieMUD.org>

Copyright

Copyright (c) 2000-2003 The FaerieMUD Consortium. All rights reserved.

This module is free software. You may use, modify, and/or redistribute this software under the terms of the Perl Artistic License. (See language.perl.com/misc/Artistic.html)

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

Required files

rbconfig   pluginfactory   mues/mixins   mues/object   mues/filters/loginsession   mues/reactorproxy  

[Validate]