Closed Hywan closed 8 years ago
See hoaproject/Socket#26 for the work on Hoa\Socket
.
With this strategy, we ensure:
Thoughts @hoaproject/hoackers?
I find the code hard to reason about.
a Connection\Handler: takes a Connection
a Connection: is a child of Stream i couldn't find this class takes socket information
a Client is a child of Connection takes socket information
a WebSocket\Connection is a child of Handler takes a Connection
a WebSocket\Client: is a child of WebSocket\Connection takes a Socket\Client
So i'm very confused with the "normal" Socket\Connection\Handler
wraps the Socket\Connection
(is one if it's properties) and the Websocket\Connection
suddenly EXTENDS Socket\Connection\Handler
My advice would be to clean up the code first and maybe make some kind of flowchart of what goes where before adding additional factories and other sort of classes. Readability & maintainability are very important when making a codebase that is suppose to be developed with a larger group.
@flip111 Here is the class: Hoa\Stream\Stream
.
The code is very clean actually. And very modular. Check the UML diagram:
documentation looks good :+1:
@flip111 :-)
Hello,
We've introduced the handling of wss://
and ws://
transport layers in PR #47. We've also introduced a new Websocket\Client
and Websocket\Server
behaviour (construct from String) in the PR #50.
The PR #47 use the work done on the Socket library in the PR hoaproject/Socket#27 with the introduction of Socket\Transport
wrapper handlers.
The Socket\Connection::setSocket
method was also updated to use the wrappers if one exists (else it fallback to the previous process): https://github.com/hoaproject/Socket/pull/27/files#diff-1dd508c79928f855d3387b0efa8b3e76R346
In the #47 wrappers for wss://
and ws://
are declared in the Websocket\Connection
file and a specific Socket
implementation is added :
Socket
: https://github.com/hoaproject/Websocket/pull/47/files#diff-ce46819b7214e93278c24115cd77d612R50The composer.json
file was also updated to ensure that wrappers are registered all the time: https://github.com/hoaproject/Websocket/pull/47/files#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780R36
Then the PR #50 introduce an update in Websocket
constructors to simplify the code. Instead of :
new Hoa\Websocket\Server(
new Hoa\Socket\Server('tcp://127.0.0.1:8889')
);
we can now write :
new Hoa\Websocket\Server('tcp://127.0.0.1:8889');
To merge all that work, we need to respect the following order :
Socket
version to be sure that the latest code will be retrieved using composer update
;Let's start by Hoa\Socket
then :-). And thanks for the summary!
Any updates on this? In #55 you said the feature would be merged within a week, however there's been no updates on the PRs since October. Would love to start using it!
@salaman Like I do :-). Be patient, it will be closed soon. I hope this week or next week, I promise ;-).
Hoa\Socket
part is merged. Now let's go for Hoa\Websocket
patches.
@salaman Almost here! Only #50 remains open. Will be closed very soon (in a couple of days).
Done!
Will fix #41.
ws://
orwss://
directly. They don't understand that we must use atcp://
URL. I can't blame them. HTTPUpgrade
is just… confusing.wss://
, we need to instanciate aHoa\Socket\Client
object withtcp://…:443
and then callenableEncryption
. Most of the time withENCRYPTION_TLS
(maybe with SSLv2 or SSLv3 sometimes, how to know?).So, yup, this is more like a factory. The same way we have
Hoa\Socket\Socket
to parsetcp://
andudp://
URL, maybe we can extend it to supportws://
andwss://
. It could be great to have an enhancedHoa\Socket\Socket
object where we could be able to register new schemes (likews://
orwss://
) in order to automatically transform a string into a realHoa\Socket\Socket
valid object (with a realtcp://
orudp://
URL). So it requires a little bit of work onHoa\Socket
.Here is the work I propose:
Hoa\Socket\Socket
:Hoa\Socket\Socket
object (or a child of),registerWrapper
andunregisterWrapper
static methods that take a “socket wrapper” interface as an argument,tcp://
andudp://
as socket wrappers.Hoa\Socket\Connection
:setSocket
method, we receive a URL; we then have to find and apply the appropriated stream wrapper to get a validHoa\Socket\Socket
object (or a child of).Hoa\Websocket\Connection
:Hoa\Websocket\Socket
(the “socket wrapper”) that extendsHoa\Socket\Socket
,ws://
andwss://
.When executing:
What is going to happen? The
ws://
andwss://
URLs are going to be transform into aHoa\Websocket\Socket
object becauseHoa\Socket\Client
is extendingHoa\Socket\Connection\Connection
. This latter will call thesetSocket
method: It will look for a valid “socket wrapper”, execute it and a validHoa\Websocket\Socket
will be created. It will be used byHoa\Websocket\Client
very smootly thanks to inheritance, but we will have more information on it, such as: Should it be encrypted? for instance (in theHoa\Websocket\Client
, we would just need to call$connection->getSocket()->isSecure()
for instance). Finally, we will have to act accordingly.Well, that's easier that what I thought!
Finally: We will have to update the documentation.