Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Websocket\Bin\Client Class Reference
Inheritance diagram for Hoa\Websocket\Bin\Client:

Public Member Functions

 main ()
 
 usage ()
 
- Public Member Functions inherited from Hoa\Console\Dispatcher\Kit
 __construct (Router $router, Dispatcher $dispatcher, View\Viewable $view=null)
 
 getOption (&$optionValue, $short=null)
 
 setOptions (Array $options)
 
 makeUsageOptionsList (Array $definitions=[])
 
 resolveOptionAmbiguity (Array $solutions)
 
 status ($text, $status)
 
 readLine ($prefix=null)
 
 readPassword ($prefix=null)
 
- Public Member Functions inherited from Hoa\Dispatcher\Kit
 __construct (Router $router, Dispatcher $dispatcher, View\Viewable $view=null)
 
 construct ()
 

Protected Attributes

 $options
 
- Protected Attributes inherited from Hoa\Console\Dispatcher\Kit
 $options = null
 
 $_options = null
 

Additional Inherited Members

- Public Attributes inherited from Hoa\Console\Dispatcher\Kit
 $parser = null
 
- Public Attributes inherited from Hoa\Dispatcher\Kit
 $router = null
 
 $dispatcher = null
 
 $view = null
 
 $data = null
 

Detailed Description

Class .

Basic WebSocket client.

Definition at line 51 of file Client.php.

Member Function Documentation

Hoa\Websocket\Bin\Client::main ( )

The entry method.

Returns
int

Definition at line 71 of file Client.php.

72  {
73  $server = '127.0.0.1:8889';
74 
75  while (false !== $c = $this->getOption($v)) {
76  switch ($c) {
77  case 's':
78  $server = $v;
79 
80  break;
81 
82  case 'h':
83  case '?':
84  return $this->usage();
85 
86  case '__ambiguous':
87  $this->resolveOptionAmbiguity($v);
88 
89  break;
90  }
91  }
92 
93 
94  $readline = new Console\Readline();
95  $client = new Websocket\Client(
96  new Socket\Client('tcp://' . $server)
97  );
98  $client->setHost('localhost');
99  $client->connect();
100 
101  do {
102  $line = $readline->readLine('> ');
103 
104  if (false === $line || 'quit' === $line) {
105  break;
106  }
107 
108  $client->send($line);
109  } while (true);
110 
111  $client->close();
112 
113  return;
114  }
getOption(&$optionValue, $short=null)
Definition: Kit.php:104
resolveOptionAmbiguity(Array $solutions)
Definition: Kit.php:190

Here is the call graph for this function:

Hoa\Websocket\Bin\Client::usage ( )

The command usage.

Returns
int

Definition at line 121 of file Client.php.

122  {
123  echo
124  'Usage : websocket:client <options>', "\n",
125  'Options :', "\n",
126  $this->makeUsageOptionsList([
127  's' => 'Server URI (default: 127.0.0.1:8889).',
128  'help' => 'This help.'
129  ]), "\n";
130 
131  return;
132  }
makeUsageOptionsList(Array $definitions=[])
Definition: Kit.php:149

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Hoa\Websocket\Bin\Client::$options
protected
Initial value:

Definition at line 58 of file Client.php.


The documentation for this class was generated from the following file: