<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/env perl

use strict;
use warnings;
use Mojo::UserAgent;
use AnyEvent::ReadLine::Gnu;
use EV;

my $ua = Mojo::UserAgent-&gt;new;
my $ws = shift @ARGV || 'wss://aitestbed.com:443/websocket';

$ua-&gt;websocket(
  $ws =&gt; sub {
    my ( $ua, $tx ) = @_;

    my $rl = new AnyEvent::ReadLine::Gnu
     prompt  =&gt; "$ws&gt; ",
     on_line =&gt; sub {
      my $i = shift;
      exit 0 if $i =~ /quit/i;
      if ( $i &amp;&amp; !$tx-&gt;is_finished ) {
        $tx-&gt;send($i);
      }
    };

    $tx-&gt;on(
      finish =&gt; sub {
        my ( $tx, $code ) = @_;
        AnyEvent::ReadLine::Gnu-&gt;print("WebSocket closed with code $code.");
        exit 0;
      }
    );

    $tx-&gt;on(
      message =&gt; sub {
        my ( $tx, $msg ) = @_;
        return if $msg =~ /notify_lr_update/;
        AnyEvent::ReadLine::Gnu-&gt;print("server: $msg\n");
      }
    );
    $tx-&gt;send('["guest_login"]');
  }
);

EV::run;

=head1 NAME

wsshell.pl - WebSocket Shell

=head1 VERSION

0.03

=cut

our $VERSION = '0.03';

=head1 DESCRIPTION

This is a command line interface to the aitestbed.com poker server. It establishes a websocket connection to the server and allows you to receive and send JSON encoded messages from the command line.  

=head1 PREREQUESITES

Mojo::UserAgent;
AnyEvent::ReadLine::Gnu;
EV;

=head1 LICENSE AND COPYRIGHT

Copyright 2016 Nathaniel Graham.

This program is free software; you can redistribute it and/or modify it
under the terms of the MIT license.

=head1 SCRIPT CATEGORIES

Networking

=cut
</pre></body></html>