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

Chatserver user class — part of the chatserver example.

Methods

Constants

MTU = 4096
CR = "\015"
LF = "\012"
EOL = CR + LF
PROMPT = 'chat> '

Attributes

ibuffer  [R]  Object attribute
obuffer  [R]  Object attribute
server  [R]  Object attribute
socket  [R]  Object attribute

Public Class methods

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

Public Instance methods

<<( string )

Alias for addOutput

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

Returns true if the user is still connected

Disconnect the user

Handle poll events on the socket

Write a prompt to the user

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.

Return a stringified version of the user

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

[Validate]