/
CDC-1.1/
parent $interfaces
object $connection_interface

var $root dbref 'connection_interface
var $root child_index 3
var $root fertile 0
var $root manager $connection_interface
var $root owned [$connection_interface]
var $root owners [$connection_interface]
var $root writable []
var $root readable ['parameters, 'methods, 'code]
var $has_commands commands []
var $has_commands shortcuts []
var $root inited 1
var $connection_interface connection 0

method timeout
    // the connection is asking the interface if it should timeout
    // and close the connection.
    return 1;
.

method parse_line
    arg line;
    var cmd;
    
    // don't use the normal parsing system because it involves
    // a bit of overhead.
    catch any {
        while (line && ((line[1]) == " "))
            line = substr(line, 2);
        if (!line) {
            return .null_cmd(line);
        } else {
            cmd = .match_command(line);
            if (cmd)
                return .(cmd[1])(@cmd[2]);
            else
                return .invalid_cmd(line);
        }
    } with handler {
        .send($parse.traceback(traceback()));
        return 'disconnect;
    }
.

method init_connection_interface
    (> .perms(caller(), $root) <);
    connection = 0;
.

method uninit_connection_interface
    (> .perms(caller(), $root) <);
    connection = 0;
.

method connection_going_away
    (> .perms(caller(), $connection) <);
    (> .perms(sender(), connection) <);
    (> .destroy() <);
.

method linelen
    return 79;
.

method new_connection
    arg addr;
    
    (> .perms(caller(), $connection) <);
    connection = sender();
.

method send
    arg what;
    
    connection.send(what);
.

method null_cmd
    arg line;
    
    return 'disconnect;
.

method invalid_cmd
    arg line;
    
    return 'disconnect;
.

method connection
    return connection;
.

method connection_starting
    // called by connection.connect()
.