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

Chatserver user class — part of the chatserver example.

Methods
<<    addOutput    connected?    disconnect    handlePollEvent    new    prompt    readInput    to_s    writeOutput   
Attributes
ibuffer  [R] 

Object attribute

obuffer  [R] 

Object attribute

server  [R] 

Object attribute

socket  [R] 

Object attribute

Public Class methods
new( socket, server )

Create and return a user object which will use the specified socket and pollObj.

Public Instance methods
to_s()

Return a stringified version of the user

addOutput( string )

Add the specified string to the user’s output buffer and turn on output events.

This method is also aliased as <<
<<( string )

Alias for addOutput

writeOutput()

Write as much of the output buffer to the socket as possible, and return the number of bytes remaining to be sent.

prompt()

Write a prompt to the user

readInput()

Read at most MTU bytes from the socket and append them to the input buffer. Split off any complete lines (one that end with EOL) and return them as an Array of Strings.

handlePollEvent( io, evmask )

Handle poll events on the socket

disconnect( msg='' )

Disconnect the user

connected?()

Returns true if the user is still connected