module BBS
The bbs gem: a library for telnet BBS servers. Requiring it loads the whole library. Configure it with BBS.configure, then start the server with BBS.start:
require 'bbs' BBS.configure do |c| c.port = 2323 c.flow = MY_FLOW end BBS.start
See README.md for the guide.
Constants
- Event
-
A normalised event delivered to widgets.
kind โ :key, :mouse, :idle, :resize, :tick key โ Symbol (:up, :enter, :f1, โฆ) or single-char String (for :key) mouse โ Telnet::MouseEvent (for :mouse) x, y โ terminal-relative cursor position (for :mouse)
For :resize,
xandyhold the new columns and rows.
Public Class Methods
# File lib/bbs.rb, line 118 def self.background(name, every: nil, retry_after: Background::RETRY_AFTER, max_retry: Background::MAX_RETRY, &) Background.new(name, every: every, retry_after: retry_after, max_retry: max_retry, &).start end
Runs the block in a BBS::Background thread named name and returns the Thread. An error is logged with BBS.log and the block run again after retry_after seconds, doubled after each failure up to max_retry.
- every
-
nil(the default) runs the block until it succeeds once; a number of seconds runs it forever, that long apart - retry_after
-
seconds before the first retry (
Background::RETRY_AFTER) - max_retry
-
the longest pause between retries (
Background::MAX_RETRY)
BBS.background('catalog refresh', every: 3600) { library.refresh }
Source
# File lib/bbs.rb, line 85 def self.config @config ||= Config.new end
The global BBS::Config, created with its defaults on first use.
# File lib/bbs.rb, line 82 def self.configure = yield(config)
Yields the global BBS::Config (created on first use) so the block can set its fields. Returns the blockโs value.
Source
# File lib/bbs.rb, line 103 def self.log(tag, message) message = "#{message.class}: #{message.message}" if message.is_a?(Exception) warn "#{config.log_tag}: #{tag}: #{message}" end
Writes one line to the log (stderr): the boardโs BBS.config.log_tag, tag (what the line is about) and message, a String or an exception (its class and message).
BBS.log('catalog refresh', error) # "feedia-bbs: catalog refresh: SocketError: โฆ"
Returns nil.
Source
# File lib/bbs.rb, line 92 def self.start(port: config.port) Server.new(port: port).run end
Starts a BBS::Server listening on port (default: BBS.config.port) on all interfaces and serves callers until the process is interrupted. Blocks; returns nil after Ctrl-C.