Elephant.io客户端无法正常工作 [英] Elephant.io Client not working

查看:170
本文介绍了Elephant.io客户端无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于socket.io的Websocket-Server,应该从php应用程序获取通知.我发现 http://elephant.io/似乎是执行此操作的正确库.似乎Elephant.io已针对作曲家进行了优化,因为没有它们,我找不到使用它的任何示例,而我自己尝试一下,则会遇到包含文件丢失的无尽错误.

I've a socket.io based Websocket-Server which should get notifications from a php application. I found http://elephant.io/ which seems to be the right library for doing this. It seems that elephant.io is optimized for composer because i can't find any example for using it without them and by trying it on my own I get endless errors of includes files which are missing.

因此,我是第一次安装composer,并且在lib \ composer文件夹中安装了Elephant.io数据包,因此该库的所有文件都位于lib \ composer \ vendor \ wisembly中. http://elephant.io/#usage 中的示例不起作用,因为客户端的构造函数没有t接受这些参数.它只有两个参数,第一个必须是ElephantIO \ EngineInterface的实例,因此我尝试了以下操作:

So I installed composer the first time and the elephant.io packet in the folder lib\composer so all files of this library are located in lib\composer\vendor\wisembly. The example from http://elephant.io/#usage is not working because the constructor of the Client doesn't accept these parameters. It has only two arguments and the first one must be a instance of ElephantIO\EngineInterface so I tried the following:

error_reporting(E_ALL);
ini_set('display_errors', true);

require_once __DIR__ . '/lib/composer/vendor/autoload.php';

use ElephantIO\Client as Elephant;
use ElephantIO\Engine\SocketIO as Version1X;

$elephant = new Elephant(new Version1X('http://mywsserver.com:8000'));

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

echo 'tryin to send `bar` to the event `foo`';

但是它也不起作用:

Fatal error: Class 'ElephantIO\Engine\SocketIO' not found in C:\inetpub\wwwroot\test.php on line 11

我是作曲者的新手,但对我来说,这个系统似乎应该通过包含autoloader-file来处理所有包含内容.

I'm new to composer but for me it seems that this system should be handling all the including-stuff by including the autoloader-file.

我只想将通知从php-app发送到socket.io服务器,这似乎很难做到.我找到的唯一替代方法是 https://github.com/rase-/socket.io -php-emitter ,但这需要redis.我不会这样,因为我使用Windows,而我的应用程序也不会从Redis中获利,因为我只有一台服务器.

I just want to send notifications from a php-app to a socket.io server, it seems very hard to do that. The only alternative I found is https://github.com/rase-/socket.io-php-emitter but this one required redis. I wouldn't like this because I'm using Windows and my application wouldn't profit from redis because I have only one server.

没有简单的方法可以做到这一点吗?我在使用socket.io之前就使用了phpws,它工作得很好,但是与以前用作服务器的.NET库相比,socket.io似乎是一个更好的解决方案,所以我宁愿继续使用socket.io./p>

Isn't there an easy way to do this? I used phpws before I'm using socket.io, this worked perfectly, but socket.io seems to be a better solution instead of the .NET library I used as server before, so I would prefer to keep on socket.io.

推荐答案

我以前使用过ElephantIO,而我所做的就是创建自己的php自动加载器.作曲家应该已经完成​​了,但是从代码中看不到哪里出了问题.无论如何,这是我的autoloader.php

I used ElephantIO before and what I did was create my own php autoloader. composer should have done it but can't see where you went wrong from the code. Anyway this was my autoloader.php

require_once("src/Client.php");
require_once("src/EngineInterface.php");
require_once("src/AbstractPayload.php");
require_once("src/Exception/SocketException.php");
require_once("src/Exception/MalformedUrlException.php");
require_once("src/Exception/ServerConnectionFailureException.php");
require_once("src/Exception/UnsupportedActionException.php");
require_once("src/Exception/UnsupportedTransportException.php");

require_once("src/Engine/AbstractSocketIO.php");
require_once("src/Engine/SocketIO/Session.php");
require_once("src/Engine/SocketIO/Version0X.php");
require_once("src/Engine/SocketIO/Version1X.php");
require_once("src/Payload/Decoder.php");
require_once("src/Payload/Encoder.php");

这篇关于Elephant.io客户端无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆