8
8
*
9
9
* New BSD License
10
10
*
11
- * Copyright © 2007-2015, Ivan Enderlin . All rights reserved.
11
+ * Copyright © 2007-2015, Hoa community . All rights reserved.
12
12
*
13
13
* Redistribution and use in source and binary forms, with or without
14
14
* modification, are permitted provided that the following conditions are met:
45
45
*
46
46
* Basic WebSocket client.
47
47
*
48
- * @author Ivan Enderlin <[email protected] >
49
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
48
+ * @copyright Copyright © 2007-2015 Hoa community
50
49
* @license New BSD License
51
50
*/
52
-
53
- class Client extends Console \Dispatcher \Kit {
54
-
51
+ class Client extends Console \Dispatcher \Kit
52
+ {
55
53
/**
56
54
* Options description.
57
55
*
58
- * @var \Hoa\Websocket\Bin\Client array
56
+ * @var array
59
57
*/
60
58
protected $ options = [
61
59
['server ' , Console \GetOption::REQUIRED_ARGUMENT , 's ' ],
@@ -68,27 +66,28 @@ class Client extends Console\Dispatcher\Kit {
68
66
/**
69
67
* The entry method.
70
68
*
71
- * @access public
72
69
* @return int
73
70
*/
74
- public function main ( ) {
75
-
71
+ public function main ()
72
+ {
76
73
$ server = '127.0.0.1:8889 ' ;
77
74
78
- while (false !== $ c = $ this ->getOption ($ v )) switch ($ c ) {
75
+ while (false !== $ c = $ this ->getOption ($ v )) {
76
+ switch ($ c ) {
77
+ case 's ' :
78
+ $ server = $ v ;
79
79
80
- case 's ' :
81
- $ server = $ v ;
82
- break ;
80
+ break ;
83
81
84
- case 'h ' :
85
- case '? ' :
86
- return $ this ->usage ();
87
- break ;
82
+ case 'h ' :
83
+ case '? ' :
84
+ return $ this ->usage ();
88
85
89
- case '__ambiguous ' :
90
- $ this ->resolveOptionAmbiguity ($ v );
91
- break ;
86
+ case '__ambiguous ' :
87
+ $ this ->resolveOptionAmbiguity ($ v );
88
+
89
+ break ;
90
+ }
92
91
}
93
92
94
93
@@ -100,15 +99,14 @@ public function main ( ) {
100
99
$ client ->connect ();
101
100
102
101
do {
103
-
104
102
$ line = $ readline ->readLine ('> ' );
105
103
106
- if (false === $ line || 'quit ' === $ line )
104
+ if (false === $ line || 'quit ' === $ line ) {
107
105
break ;
106
+ }
108
107
109
108
$ client ->send ($ line );
110
-
111
- } while (true );
109
+ } while (true );
112
110
113
111
$ client ->close ();
114
112
@@ -118,17 +116,17 @@ public function main ( ) {
118
116
/**
119
117
* The command usage.
120
118
*
121
- * @access public
122
119
* @return int
123
120
*/
124
- public function usage ( ) {
125
-
126
- echo 'Usage : websocket:client <options> ' , "\n" ,
127
- 'Options : ' , "\n" ,
128
- $ this ->makeUsageOptionsList ([
129
- 's ' => 'Server URI (default: 127.0.0.1:8889). ' ,
130
- 'help ' => 'This help. '
131
- ]), "\n" ;
121
+ public function usage ()
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" ;
132
130
133
131
return ;
134
132
}
0 commit comments