Class Server
In: examples/chatserver.rb
Parent: Object

Example chatserver class — an extremely crude and simple chat server that demonstrates how to use Poll to do multiplexing IO in a single thread.

Methods

Constants

BANNER = <<-EOF [[ Ruby-Poll Example Chatserver ]] Commands: '/quit' to quit, '/shutdown' to shut the server down EOF

Attributes

pollObj  [R]  Server attributes
socket  [R]  Server attributes
users  [R]  Server attributes

Public Class methods

Instantiate and return a chatserver on the specified host and port

Public Instance methods

Broadcast the specified message to all connected users

Broadcast the specified message from the specified user

Disconnect all connected users

Disconnect the specified user

Handle the specified command from the specified user

Handle a poll event specified by evmask on the specified socket

Main server loop

Process the specified input from the specified user

Build and return a list of connected users for the specified user.

[Validate]