-
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?
Changes from all commits
8521357
38916a9
7c42f34
9008bd1
cc726ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,9 @@ public function connect() | |
return; | ||
} | ||
|
||
$this->handshake(); | ||
if($this->options['transport'] != 'websocket'){ | ||
$this->handshake(); | ||
} | ||
|
||
$protocol = 'http'; | ||
$errors = [null, 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 commentThe reason will be displayed to describe this comment to others. Learn more. It seems that the package requires And it can consider using the ......
$this->session->id ?? null,
......
This comment was marked as outdated.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. ok i will update it |
||
'EIO' => $this->options['version'], | ||
'transport' => static::TRANSPORT_WEBSOCKET]; | ||
|
||
|
@@ -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 commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. or maybe we can by pass run write if session null? |
||
if ($this->session->needsHeartbeat()) { | ||
$this->write(static::PING); | ||
} | ||
} | ||
} | ||
} |
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:
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...