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

Automatically determine which version of Socket.io is used #63

Open
kbu1564 opened this issue Aug 28, 2014 · 2 comments
Open

Automatically determine which version of Socket.io is used #63

kbu1564 opened this issue Aug 28, 2014 · 2 comments

Comments

@kbu1564
Copy link
Contributor

kbu1564 commented Aug 28, 2014

The Version 0.X and 1.X of Socket.io is get the version of /socket.io/socket.io.js like next.

public function getVersion()
{
    // get socket.io version
    $url = 'http://' . $this->url['host'] . ':' . $this->url['port'];
    if (true === $this->url['secured']) {
        $url = 'https://' . $this->url['host'] . ':' . $this->url['port'];
    }

    $url .= '/socket.io/socket.io.js';
    // need to ini_set('allow_url_fopen', 'On');
    $socketio = file_get_contents($url);
    preg_match_all('/io\.version = [\'\"]([0-9\.]+)[\'\"];/', $socketio, $match);

    if (isset($match[1]) === false)
        return '1.x.x';

    return $match[1][0];
}

If elephant.io/src/Client.php of refacto-3.0 is used like next, i want to listen for your think.

// The Client class was used getVersion() into the Client::__construct.
$client = new Client('http://localhost:9001');

$client->initialize();
$client->emit('broadcast', ['foo' => 'bar']);
$client->close();
@kbu1564 kbu1564 changed the title We need to get version of socket.io from server of node.js? We are need to get version of socket.io from server of node.js? Aug 28, 2014
@kbu1564 kbu1564 changed the title We are need to get version of socket.io from server of node.js? We are need to get version of socket.io from server of node.js about elephant.io of refacto-3.0? Aug 28, 2014
@Taluu
Copy link
Contributor

Taluu commented Aug 28, 2014

I don't think it should be done in the Client, as it could be used for something else than Socket.io. But, as I already discussed it in #53 (comment), it should maybe be put into a factory of some sorts.

I'll try to add something later, so I'm keeping this ticket open to leave a reminder. :)

@Taluu Taluu changed the title We are need to get version of socket.io from server of node.js about elephant.io of refacto-3.0? Automatically determine which version of Socket.io is used Aug 28, 2014
@kbu1564
Copy link
Contributor Author

kbu1564 commented Aug 28, 2014

The issue of #53 was solved about question of myself.
so i was able to understand for direction of this project.

Thanks!! :)

@Taluu Taluu added 3.0 labels Aug 28, 2014
@Taluu Taluu removed the 3.0 label Jan 30, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants