Skip to content

Instantly share code, notes, and snippets.

@BrunoBonacci
Created July 1, 2012 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrunoBonacci/3028525 to your computer and use it in GitHub Desktop.
Save BrunoBonacci/3028525 to your computer and use it in GitHub Desktop.
Vert.x Simple Telnet Server - session management
// this is the base directory where all user will be segregated (like: "chroot")
BASE_DIR = new File(System.properties.baseDir ?: "/tmp").canonicalPath;
// This map maintains the session state for every connection.
// for this telnet server the state will be limited to the current directory
_connections = [:];
// Connection id counter
_cids = 0;
// assigning an id to a new connection
def registerConnection() {
String cid = "${++_cids}"
_connections[cid] = [curDir: BASE_DIR]
return cid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment