Skip to content

Commit

Permalink
Make the telnet menu display a little prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmay committed Aug 1, 2011
1 parent cffa51f commit 1449bd5
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/App/Termcast/Server/Telnet/Dispatcher/Connection.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ use Moose;
use Time::Duration;

use constant CLEAR => "\e[2J\e[H";
use constant TELNET_MENU => join '', map { "$_\r\n" }
'Termcast -- Telnet style!',
'',
'If your terminal\'s dimensions differ from that which you want to view, please resize your terminal accordingly.',
'',
'----------';

has session_pool => (
is => 'ro',
Expand Down Expand Up @@ -64,23 +70,24 @@ sub dispatch_menu_inputs {
sub send_connection_list {
my $self = shift;
my $handle = shift;
my $output;
my $output = TELNET_MENU;

# TODO, log: print "Sending stream menu to the customer\n";
my $letter = 'a';
my @stream_data = $self->unix_stream_objects;
$output .= "Users connected:\r\n";
foreach my $stream (@stream_data) {
$output .= sprintf "%s) %s (%s) - Active %s\r\n",
$output .= sprintf " %s) %s (%s) - Active %s\r\n",
$letter,
$stream->username,
$stream->cols . 'x' . $stream->rows,
ago(time() - $stream->last_active->epoch);
$letter++;
}

$output = "No active termcast sessions!\r\n" if !$output;
$output = " No active termcast sessions!\r\n" if !$output;

$handle->syswrite(CLEAR . "Users connected:\r\n\r\n$output");
$handle->syswrite(CLEAR . $output);
}

sub get_stream_from_key {
Expand Down

0 comments on commit 1449bd5

Please sign in to comment.