Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

skip handshake if using websocket as transport. #197

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

adamzul
Copy link

@adamzul adamzul commented Feb 8, 2020

websocket transport is use full if socket server multi node and not stick.

…s use full if socket server multi node and not stick.
Copy link
Contributor

@Taluu Taluu left a 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 ?

@adamzul
Copy link
Author

adamzul commented Feb 9, 2020

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'){
Copy link
Contributor

@peter279k peter279k Feb 10, 2020

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') {
......

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be if (...) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give space between ')' and '{' ?

Copy link
Contributor

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?

Copy link
Contributor

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){
Copy link
Contributor

@peter279k peter279k Feb 10, 2020

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) {
......

Copy link
Contributor

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;
}

// ...

Copy link
Contributor

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.

Copy link
Author

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,
Copy link
Contributor

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.

Copy link
Contributor

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)

Copy link
Author

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

@Taluu
Copy link
Contributor

Taluu commented Sep 21, 2020

Any status update here ? I'm okay for allowing to "skip" the handshake if needed (didn't verify, I trust you guys :P).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants