varspool / Wrench

A simple PHP WebSocket implementation for PHP 7.1
Do What The F*ck You Want To Public License
596 stars 210 forks source link

Client received cleanup after each receive call #121

Closed choval closed 6 years ago

choval commented 6 years ago

/lib/Client.php onData just keeps pushing payloads to the received array without ever cleaning it.

If the Wrench client is run in a loop, the array just keeps growing. I don't see any reason to keep the previous received messages and calculating the diff on each receive() call.

choval commented 6 years ago

Test fails because it expects the message to be at index '2', but the response array is reset and should expect the response to be at '0' .

From: `

test fix for issue #43

        $responses = $instance->receive();
        $this->assertTrue(is_array($responses));
        $this->assertCount(1, $responses);
        $this->assertInstanceOf(Payload::class, $responses[2]);

`

Should be: `

test fix for issue #43

        $responses = $instance->receive();
        $this->assertTrue(is_array($responses));
        $this->assertCount(1, $responses);
        $this->assertInstanceOf(Payload::class, $responses[0]);

`