class Session

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

Attributes

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

Public Class Methods

new(server, sock=nil) click to toggle source

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.

# 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() click to toggle source

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

# File lib/network/session.rb, line 54
def handle_close
end
handle_input() click to toggle source

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

# File lib/network/session.rb, line 46
def handle_input
end
handle_oob() click to toggle source

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

# File lib/network/session.rb, line 59
def handle_oob
end
handle_output() click to toggle source

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

# File lib/network/session.rb, line 50
def handle_output
end
init() click to toggle source

init is called before using the session.

returns

true is session object properly initialized

# File lib/network/session.rb, line 41
def init
  true
end
is_readable?() click to toggle source

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

# File lib/network/session.rb, line 64
def is_readable?
  @connected || @accepting
end
is_writable?() click to toggle source

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

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