Skip to content

Commit fd12ccd

Browse files
committed
Buffer can now be injected into Socket
1 parent f5aee90 commit fd12ccd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Datagram/Socket.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ class Socket extends EventEmitter implements SocketInterface
1414

1515
public $bufferSize = 65536;
1616

17-
public function __construct(LoopInterface $loop, $socket)
17+
public function __construct(LoopInterface $loop, $socket, Buffer $buffer = null)
1818
{
1919
$this->loop = $loop;
2020
$this->socket = $socket;
2121

22-
$this->buffer = new Buffer($loop, $socket);
22+
if ($buffer === null) {
23+
$buffer = new Buffer($loop, $socket);
24+
}
25+
$this->buffer = $buffer;
26+
2327
$that = $this;
2428
$this->buffer->on('error', function ($error) use ($that) {
2529
$that->emit('error', array($error, $that));

0 commit comments

Comments
 (0)