@@ -78,13 +78,13 @@ public function close()
7878 $ this ->listening = false ;
7979 $ this ->data = '' ;
8080
81- $ this ->emit ('close ' );
81+ $ this ->emit ('close ' , [ $ this ] );
8282 }
8383
8484 public function handleWrite ()
8585 {
8686 if (!is_resource ($ this ->stream ) || ('generic_socket ' === $ this ->meta ['stream_type ' ] && feof ($ this ->stream ))) {
87- $ this ->emit ('error ' , array (new \RuntimeException ('Tried to write to closed or invalid stream. ' )));
87+ $ this ->emit ('error ' , array (new \RuntimeException ('Tried to write to closed or invalid stream. ' ), $ this ));
8888
8989 return ;
9090 }
@@ -96,20 +96,23 @@ public function handleWrite()
9696 restore_error_handler ();
9797
9898 if (false === $ sent ) {
99- $ this ->emit ('error ' , array (new \ErrorException (
100- $ this ->lastError ['message ' ],
101- 0 ,
102- $ this ->lastError ['number ' ],
103- $ this ->lastError ['file ' ],
104- $ this ->lastError ['line ' ]
105- )));
99+ $ this ->emit ('error ' , array (
100+ new \ErrorException (
101+ $ this ->lastError ['message ' ],
102+ 0 ,
103+ $ this ->lastError ['number ' ],
104+ $ this ->lastError ['file ' ],
105+ $ this ->lastError ['line ' ]
106+ ),
107+ $ this
108+ ));
106109
107110 return ;
108111 }
109112
110113 $ len = strlen ($ this ->data );
111114 if ($ len >= $ this ->softLimit && $ len - $ sent < $ this ->softLimit ) {
112- $ this ->emit ('drain ' );
115+ $ this ->emit ('drain ' , [ $ this ] );
113116 }
114117
115118 $ this ->data = (string ) substr ($ this ->data , $ sent );
@@ -118,7 +121,7 @@ public function handleWrite()
118121 $ this ->loop ->removeWriteStream ($ this ->stream );
119122 $ this ->listening = false ;
120123
121- $ this ->emit ('full-drain ' );
124+ $ this ->emit ('full-drain ' , [ $ this ] );
122125 }
123126 }
124127
0 commit comments