Git Product home page Git Product logo

miniboa's Introduction

Miniboa: a simple Telnet server

build status downloads

What?

Miniboa is a bare-bones Telnet server to use as the base for a MUD or similar interactive server. Miniboa has several nice features for this type of application.

Features

  • Asynchronous - no waiting on player input or state.
  • Single threaded - light on resources with excellent performance.
  • Runs under your game loop - you decide when to poll for data.
  • Supports 1000 users under Linux and 512 under Windows (untested).
  • Miniboa is compatable with both Python 2.6, 2.7, and 3.

Quick Start

First:

pip install miniboa

And then:

from miniboa import TelnetServer
server = TelnetServer()
while True: server.poll()

But you probably want to do something with the connecting/disconnecting clients:

CLIENTS = []

def on_connect(client):
    client.send("Hello, my friend. Stay awhile and listen.")
    CLIENTS.append(client)

def on_disconnect(client):
    CLIENTS.remove(client)

server = TelnetServer(
    port = 3333,
    address = '',
    on_connect = on_connect,
    on_disconnect = on_disconnect,

while True:
    server.poll()

To use Miniboa, you create a Telnet Server object listening at a specified port number. You have to provide two functions for the server; the first is a handler for new connections and the second is the handler for lost connections. These handler functions are passed Telnet Client objects -- these are your communication paths to and from the individual player's MUD client.

For example, let's say Mike and Joe connect to your MUD server. Telnet Server will call your on_connect() function with Mike's Telnet Client object, and then again with Joe's Telnet Client object. If Mike's power goes out, Telnet Server will call your on_disconnect() function with Mike's Telnet Client object (same exact one).

This will launch a server listening on the default port, that accepts Telnet connections and sends a simple message.

$ telnet localhost 7777
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Hello, my friend. Stay awhile and listen.

Further documentation can be found here.

Copyright

Copyright 2009 Jim Storch
Copyright 2015 Carey Metcalfe
Copyright 2016 Joseph Schilz
Copyright 2016 Jared Miller

miniboa's People

Contributors

shmup avatar pr0ps avatar

Watchers

Christopher Bond avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.