-
Notifications
You must be signed in to change notification settings - Fork 366
skip handshake if using websocket as transport. #197
base: master
Are you sure you want to change the base?
Conversation
…s use full if socket server multi node and not stick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uneasy on how this is done, especially the part on upgradeTransport
(it should do nothing if we're already on websocket).
Are we sure there's no handshakes to be made first ?
i get problem if my socket server using multi node and using polling transport, which need server to make session id. but session id only recognized by the node that created it. so then i try using websocket transport. as far as i know if we use websocket , we not using handshake . In current code, it force to make handshake and make session from server |
@@ -42,7 +42,9 @@ public function connect() | |||
return; | |||
} | |||
|
|||
$this->handshake(); | |||
if($this->options['transport'] != 'websocket'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make coding style consistency? And this code snippet should be:
......
if ($this->options['transport'] != 'websocket') {
......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be if (...) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
give space between ')' and '{' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Taluu, maybe it should consider some coding style to check during Travis CI build.
We can consider using PHP_CodeSniffer or PHP-CS-Fixer.
Do you have any idea about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, adding this (with maybe building through GA instead of Travis) would be awesome. Not sure I have the time for that currently though, especially as I'm not really maintaining it (because not using it...) currently...
@@ -308,8 +310,10 @@ protected function upgradeTransport() | |||
*/ | |||
public function keepAlive() | |||
{ | |||
if ($this->session->needsHeartbeat()) { | |||
$this->write(static::PING); | |||
if($this->session){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be:
......
if ($this->session) {
......
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better :
if ($this->session === null) {
return;
}
// ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then we can't keep alive the connection, it will be closed at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe we can by pass run write if session null?
@@ -239,7 +241,7 @@ protected function handshake() | |||
*/ | |||
protected function upgradeTransport() | |||
{ | |||
$query = ['sid' => $this->session->id, | |||
$query = ['sid' => isset($this->session->id) ? $this->session->id : null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the package requires php-7.1
version at least.
And it can consider using the ??
syntax:
......
$this->session->id ?? null,
......
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, didn't remember it was bumped 10 months ago. 😂
(We should still bump to maintained php versions though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i will update it
Any status update here ? I'm okay for allowing to "skip" the handshake if needed (didn't verify, I trust you guys :P). |
websocket transport is use full if socket server multi node and not stick.