Y
Y
Yuri Petrashevich2015-11-05 16:56:42
PHP
Yuri Petrashevich, 2015-11-05 16:56:42

Elephant.io - how to open a connection just once?

using elephant.io to transfer data from php to nodejs
here is the transfer code:

public function emit($data) {
    $log = new Log();
    $elephant = new Elephant(new Version1X('http://localhost:2222'));
    $elephant->initialize();
    $elephant->emit($data);
    $elephant->close();
  }

At high loads, the connection establishment time is 0.5-1 second, so you need this connection to be opened once and for all (of course, until I close it). For example, put it all in a separate file, at the start of which a connection is opened and then, for example,
while (1) { ... }
data should be listened through, which I will somehow send from another php script. Does anyone have any ideas on how to properly implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Lyzlov, 2015-11-05
@dixoNich

$elephant = new Elephant(new Version1X('http://localhost:2222'));
$elephant->initialize();
public function emit($data) {
    $log = new Log();
    $elephant->emit($data);
 }

What for you connection open on each emit?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question