You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue/scenario is that I would like to create a custom Connection and I am wondering what is the best way of doing it.
There are two possible ways that I can think of:
Allow extending Server by changing scope of $loop to protected.
Add a factory (like) connection class property in Server
Details for both approaches below, but first is there any reason for keeping $loop private in React\Socket\Server?
Approach 1 - changing scope of $loop to protected:
Changing scope to protected, then extending it via MyCustomServer in which I can override createConnection.
This approach is demonstrated below.
/** @event connection */classServerextendsEventEmitterimplementsServerInterface
{
public$master;
protected$loop; // changing scope from private to protected
....
}
/** MY Custom Server Class */classMyCustomServerextendsServer
{
publicfunctioncreateConnection($socket)
{
returnnewCustomConnection($socket, $this->loop);
}
}
Approach 2 - Connection class property
Have a factory (sort of) way of creating a connection, in which a Server's property can be overwritten to create a connection e.g.
The issue/scenario is that I would like to create a custom
Connection
and I am wondering what is the best way of doing it.There are two possible ways that I can think of:
Server
by changing scope of$loop
to protected.Server
Details for both approaches below, but first is there any reason for keeping $loop private in
React\Socket\Server
?Approach 1 - changing scope of
$loop
to protected:Changing scope to
protected
, then extending it viaMyCustomServer
in which I can overridecreateConnection
.This approach is demonstrated below.
Approach 2 - Connection class property
Have a factory (sort of) way of creating a connection, in which a
Server
's property can be overwritten to create a connection e.g.The text was updated successfully, but these errors were encountered: