set_connection_handlers {
    # new connection
    NEW => {
	START => sub {
	    set_timeout();
	},

	STOP => sub {
	    cancel_timeout();
	},
	
	# new conversation on this connection
	NEW => {
	    # message types / triggers:
	    hello_mux => sub {
		my ($deployment, $time) = @fields{qw(deployment time)};
		my @customers = split /\s+/, $fields{customers};
		
		if (abs(time - $time) > $MAX_TIME_DIFF) {
		    # the time difference is too great - reply with an error
		    reply( 'error',
			   code    => 1,
			   message => 'clocks are not synchronized' );
		    reset_timeout();
		    return;
		}

		$con->{deployment} = $deployment;
		$con->{customers} = \@customers;
		
		# index this connection - TODO: are customer_names globally unique, or only within a deployment?
		#                               can more than one server provide access to a single customer?
		push @{ $con_by_deployment{$deployment} }, $con;
		for my $customer (@customers) {
		    $con_by_deployment_customer{$deployment}{$customer} = $con;
		}

		# send a welcoming reply - TODO: could do this earlier?
		reply('welcome');

		set_connection_type('mux');
		
		message('connection from mux activated');

		stop_conversation();
	    }

	    
	}
    }

    # message on a mux connection
    mux => 

    # 
};
