File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -74,4 +74,9 @@ public function close()
74
74
$ this ->outgoing = array ();
75
75
$ this ->removeAllListeners ();
76
76
}
77
+
78
+ public function end ()
79
+ {
80
+
81
+ }
77
82
}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class Socket extends EventEmitter implements SocketInterface
11
11
protected $ socket ;
12
12
13
13
protected $ buffer ;
14
+ protected $ writable = true ;
14
15
15
16
public $ bufferSize = 65536 ;
16
17
@@ -93,12 +94,30 @@ public function close()
93
94
$ this ->pause ();
94
95
95
96
fclose ($ this ->socket );
97
+ $ this ->writable = false ;
96
98
$ this ->socket = false ;
97
99
$ this ->buffer ->close ();
98
100
99
101
$ this ->removeAllListeners ();
100
102
}
101
103
104
+ public function end ()
105
+ {
106
+ if (!$ this ->writable ) {
107
+ return ;
108
+ }
109
+
110
+ $ this ->writable = false ;
111
+
112
+ $ that = $ this ;
113
+
114
+ $ this ->buffer ->on ('close ' , function () use ($ that ) {
115
+ $ that ->close ();
116
+ });
117
+
118
+ $ this ->buffer ->end ();
119
+ }
120
+
102
121
private function sanitizeAddress ($ address )
103
122
{
104
123
// doc comment suggests IPv6 address is not enclosed in square brackets?
Original file line number Diff line number Diff line change 10
10
* @event message($data, $remoteAddress, $thisSocket)
11
11
* @event error($exception, $thisSocket)
12
12
* @event close($thisSocket)
13
+ * @event end($thisSocket);
13
14
*/
14
15
interface SocketInterface extends EventEmitterInterface
15
16
{
16
17
public function send ($ data , $ remoteAddress = null );
17
18
18
19
public function close ();
19
20
21
+ public function end ();
22
+
20
23
public function resume ();
21
24
22
25
public function pause ();
You can’t perform that action at this time.
0 commit comments