9
9
use Amp \Http \Client \Response ;
10
10
use Amp \Socket \SocketAddress ;
11
11
use Amp \Socket \TlsInfo ;
12
- use Amp \Websocket \CloseCode ;
13
12
use Amp \Websocket \Rfc6455Client ;
14
- use Amp \Websocket \WebsocketClientMetadata ;
13
+ use Amp \Websocket \WebsocketCloseCode ;
14
+ use Amp \Websocket \WebsocketCount ;
15
15
use Amp \Websocket \WebsocketMessage ;
16
+ use Amp \Websocket \WebsocketTimestamp ;
17
+ use Traversable ;
16
18
17
- final class Rfc6455Connection implements WebsocketConnection
19
+ final class Rfc6455Connection implements WebsocketConnection, \IteratorAggregate
18
20
{
19
21
use ForbidCloning;
20
22
use ForbidSerialization;
@@ -63,11 +65,6 @@ public function isClosedByPeer(): bool
63
65
return $ this ->client ->isClosedByPeer ();
64
66
}
65
67
66
- public function getUnansweredPingCount (): int
67
- {
68
- return $ this ->client ->getUnansweredPingCount ();
69
- }
70
-
71
68
public function getCloseCode (): int
72
69
{
73
70
return $ this ->client ->getCloseCode ();
@@ -78,19 +75,19 @@ public function getCloseReason(): string
78
75
return $ this ->client ->getCloseReason ();
79
76
}
80
77
81
- public function send (string $ data ): void
78
+ public function sendText (string $ data ): void
82
79
{
83
- $ this ->client ->send ($ data );
80
+ $ this ->client ->sendText ($ data );
84
81
}
85
82
86
83
public function sendBinary (string $ data ): void
87
84
{
88
85
$ this ->client ->sendBinary ($ data );
89
86
}
90
87
91
- public function stream (ReadableStream $ stream ): void
88
+ public function streamText (ReadableStream $ stream ): void
92
89
{
93
- $ this ->client ->stream ($ stream );
90
+ $ this ->client ->streamText ($ stream );
94
91
}
95
92
96
93
public function streamBinary (ReadableStream $ stream ): void
@@ -103,17 +100,22 @@ public function ping(): void
103
100
$ this ->client ->ping ();
104
101
}
105
102
106
- public function getInfo (): WebsocketClientMetadata
103
+ public function getCount (WebsocketCount $ type ): int
104
+ {
105
+ return $ this ->client ->getCount ($ type );
106
+ }
107
+
108
+ public function getTimestamp (WebsocketTimestamp $ type ): int
107
109
{
108
- return $ this ->client ->getInfo ( );
110
+ return $ this ->client ->getTimestamp ( $ type );
109
111
}
110
112
111
113
public function isClosed (): bool
112
114
{
113
115
return $ this ->client ->isClosed ();
114
116
}
115
117
116
- public function close (int $ code = CloseCode ::NORMAL_CLOSE , string $ reason = '' ): void
118
+ public function close (int $ code = WebsocketCloseCode ::NORMAL_CLOSE , string $ reason = '' ): void
117
119
{
118
120
$ this ->client ->close ($ code , $ reason );
119
121
}
@@ -122,4 +124,14 @@ public function onClose(\Closure $onClose): void
122
124
{
123
125
$ this ->client ->onClose ($ onClose );
124
126
}
127
+
128
+ public function isCompressionEnabled (): bool
129
+ {
130
+ return $ this ->client ->isCompressionEnabled ();
131
+ }
132
+
133
+ public function getIterator (): Traversable
134
+ {
135
+ yield from $ this ->client ;
136
+ }
125
137
}
0 commit comments