Giter Club home page Giter Club logo

Comments (6)

modao avatar modao commented on August 18, 2024

It seems that now callback in emit is ignored. Here is the source code
/**
* Emit an event
*
* @param string $event
* @param array $args
* @param string $endpoint
* @param function $callback - ignored for the time being
* @return ElephantIO\Client
* @todo work on callbacks
*/
public function emit($event, $args, $endpoint = null, $callback = null) {
return $this->send(self::TYPE_EVENT, null, $endpoint, json_encode(array(
'name' => $event,
'args' => $args,
)
));
}

from elephant.io.

Taluu avatar Taluu commented on August 18, 2024

you could maybe play a little bit with the events (implemented in #39) ? But i'm not sure how to fire these events though.

from elephant.io.

impanda-cookie avatar impanda-cookie commented on August 18, 2024

@Taluu the #39 nodejs server side socket.io on does not implement callback. if i modify #39 nodejs service side code like this:

var io = require('socket.io').listen(8000);
io.sockets.on('connection', function (socket) {
console.log('user connected');
socket.on('ping', function (data,callback) {
     console.log('Ping received with data: ' + data);
     // socket.emit('pong', '42');
     // callback(something);
     //`callback` will be undefined.
  });
});

The callback is not undefined. I hope my php client side implement the callback can be like this:

$elephant->emit('ping', $json, null,function($d) use(&$elephant){
 var_dump($d);  //callback the nodejs server side `on`  function
 $elephant->close();
});

What should I do please?

from elephant.io.

Taluu avatar Taluu commented on August 18, 2024

If I get this right, what you are trying to do is execute a php function in your node.js service, which is, AFAIK, not possible.

The callback in this case shoud, I think, be some javascript executable (a function name, a js callback, ...) for socket.io to call whenever it receives an event.

What you're trying to do is to call a callback when you're emitting... hence the solution pointing to #39 implementation. But it will need to work a little bit around that to achieve what you want, if that is what you want...

from elephant.io.

zhangyaoxing avatar zhangyaoxing commented on August 18, 2024

It seems to me he's not trying to execute php function in nodejs service. Instead he needs the callback of emit. And execute the php function in the callback. It's supported by the SocketIO protocol but not implemented in elephant.io anyhow. I had same issue when using .NET client. And is interested in how to do this in php, too. @Taluu Could you be more specific?

from elephant.io.

Taluu avatar Taluu commented on August 18, 2024

Closing, as this is an issue on 2.0, which is not maintained anymore

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.