v0.6.0
-
Feature / BC break: Use
connect($uri)
instead ofcreate($host, $port)
and resolve with aConnectionInterface
instead ofStream
and expose remote and local addresses through this interface
and remove superfluous and undocumentedConnectionException
.
(#74, #82 and #84 by @clue)// old $connector->create('google.com', 80)->then(function (Stream $conn) { echo 'Connected' . PHP_EOL; $conn->write("GET / HTTP/1.0\r\n\r\n"); }); // new $connector->connect('google.com:80')->then(function (ConnectionInterface $conn) { echo 'Connected to ' . $conn->getRemoteAddress() . PHP_EOL; $conn->write("GET / HTTP/1.0\r\n\r\n"); });
Note that both the old
Stream
and the newConnectionInterface
implement
the same underlyingDuplexStreamInterface
, so their streaming behavior is
actually equivalent.
In order to upgrade, simply use the new typehints.
Existing stream handlers should continue to work unchanged. -
Feature / BC break: All connectors now MUST offer cancellation support.
You can now rely on getting a rejected promise when callingcancel()
on a
pending connection attempt.
(#79 by @clue)// old: promise resolution not enforced and thus unreliable $promise = $connector->create($host, $port); $promise->cancel(); $promise->then(/* MAY still be called */, /* SHOULD be called */); // new: rejecting after cancellation is mandatory $promise = $connector->connect($uri); $promise->cancel(); $promise->then(/* MUST NOT be called */, /* MUST be called */);
Note that this behavior is only mandatory for pending connection attempts.
Once the promise is settled (resolved), callingcancel()
will have no effect. -
BC break: All connector classes are now marked
final
and you can no longerextend
them
(which was never documented or recommended anyway).
Please use composition instead of extension.
(#85 by @clue)