Class Session
In: lib/network/session.rb
Parent: Object
Session
Publisher
dot/f_40.png

The session class is a base class contains the minimum amount of attributes to reasonably maintain a socket session with a client.

Methods

Included Modules

Publisher

Attributes

accepting  [RW] 
closing  [RW] 
connected  [RW] 
sock  [R] 
write_blocked  [RW] 

Public Class methods

Create a new session object Used when opening both an acceptor or connection.

server
The reactor or connector this session is associated with.
sock
Nil for acceptors or the socket for connections.
returns
A session object.

[Source]

# File lib/network/session.rb, line 32
  def initialize(server, sock=nil)
    @server = server   # Reactor or connector associated with this session.
    @sock = sock       # File descriptor handle for this session.
    @addr = ""         # Network address of this socket.
    @accepting=@connected=@closing=@write_blocked=false
  end

Public Instance methods

handle_close is called when a close event occurs for this session.

[Source]

# File lib/network/session.rb, line 54
  def handle_close
  end

handle_input is called when an input event occurs for this session.

[Source]

# File lib/network/session.rb, line 46
  def handle_input
  end

handle_oob is called when an out of band data event occurs for this session.

[Source]

# File lib/network/session.rb, line 59
  def handle_oob
  end

handle_output is called when an output event occurs for this session.

[Source]

# File lib/network/session.rb, line 50
  def handle_output
  end

init is called before using the session.

returns
true is session object properly initialized

[Source]

# File lib/network/session.rb, line 41
  def init
    true
  end

is_readable? tests if the socket is a candidate for select read {return] true if so, false if not

[Source]

# File lib/network/session.rb, line 64
  def is_readable?
    @connected || @accepting
  end

is_writable? tests if the socket is a candidate for select write {return] true if so, false if not

[Source]

# File lib/network/session.rb, line 70
  def is_writable?
    @write_blocked
  end

[Validate]