Giter Club home page Giter Club logo

Comments (5)

gmajoulet avatar gmajoulet commented on July 19, 2024

Can you please post the exception you had ?

from elephant.io.

Pitel avatar Pitel commented on July 19, 2024
PHP Notice:  Undefined offset: 1 in xxx/ElephantIO/Client.php on line 238
PHP Notice:  Undefined offset: 2 in xxx/ElephantIO/Client.php on line 239
PHP Notice:  Undefined offset: 3 in xxx/ElephantIO/Client.php on line 240
PHP Fatal error:  Uncaught exception 'Exception' with message 'This socket.io server do not support websocket protocol. Terminating connection...' in xxx/ElephantIO/Client.php:242
Stack trace:
#0 xxx/ElephantIO/Client.php(51): ElephantIO\Client->handshake()
#1 xxx/client.php(6): ElephantIO\Client->init(true)
#2 {main}
  thrown in xxx/ElephantIO/Client.php on line 242

PHP 5.4.6-1ubuntu1 (cli) (built: Aug 22 2012 21:13:52)

from elephant.io.

guillaumepotier avatar guillaumepotier commented on July 19, 2024

Hi @Pitel , thanks for tryin' elephant.io!

We updated a bit the lib (2.0 tag) and unfortunately did not update the doc accordingly..

Could you please try these code parts and tell me if it works for you?

PHP Code trying to communicate with socket.io through PHP:

<?php

require('lib/ElephantIO/Client.php');
use ElephantIO\Client as ElephantIOClient;

$elephant = new ElephantIOClient('http://localhost:8000', 'socket.io', 1, false, true, true);

$elephant->init();
$elephant->send(
    ElephantIOClient::TYPE_EVENT,
    null,
    null,
    json_encode(array('name' => 'action', 'args' => 'foo'))
);
$elephant->close();

echo 'tryin to send `foo` to the event called action';

Node.js server

var io = require('socket.io').listen(8000);

io.sockets.on('connection', function (socket) {
  console.log('user connected');

  socket.on('action', function (data) {
    console.log('here we are in action event and data is: ');
    console.log(data);
  });
});

from elephant.io.

Pitel avatar Pitel commented on July 19, 2024

Oops, my bad. It seems PHP does not allow settings parameters like Python. Removing $debug = true from the constructor makes it work again. Sorry.

from elephant.io.

dangquangminh avatar dangquangminh commented on July 19, 2024

how to remove $debug = true. I can fix this issue

from elephant.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.