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
broadcastMsg    broadcastMsgFrom    disconnectAllUsers    disconnectUser    handleCommand    handlePollEvent    new    pollLoop    processInput    shutdown    wholist   
Attributes
pollObj  [R] 

Server attributes

socket  [R] 

Server attributes

users  [R] 

Server attributes

Public Class methods
new( listenHost="0.0.0.0", listenPort=1138, interval=0.20 )

Instantiate and return a chatserver on the specified host and port

Public Instance methods
pollLoop()

Main server loop

handlePollEvent( socket, evmask )

Handle a poll event specified by evmask on the specified socket

processInput( user, *inputStrings )

Process the specified input from the specified user

handleCommand( user, command, args )

Handle the specified command from the specified user

broadcastMsg( msg )

Broadcast the specified message to all connected users

broadcastMsgFrom( user, msg )

Broadcast the specified message from the specified user

disconnectUser( user, msg='' )

Disconnect the specified user

disconnectAllUsers( msg )

Disconnect all connected users

shutdown( msg="Server shutdown" )

Shut the server down

wholist( user )

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