window部署WEB消息推送框架遇到的问题

mi.com

下载的是WEB消息推送框架(window版本)
放在 http://_._._._:2121 服务器的同一目录,以下3个文件的4个地址,不知道怎么配置

\start_io.php 这个文件中的

// 监听一个http端口
$inner_http_worker = new Worker('http://0.0.0.0:2121');
//请问 http://0.0.0.0:2121 这个要写什么?自己服务器的IP?但是写了的话对应的 http://_._._._:2121 的后台服务器要做成什么的,我用的是php,这服务器的php文件要怎么部署?

还有

// PHPSocketIO服务
$sender_io = new SocketIO(2120);

这个端口是对应什么文件或服务器什么的?

\start_web.php

$web = new WebServer('http://0.0.0.0:2121');

这里的IP又是写哪个?demo说得不太清楚,

web\index.html

// 连接服务端
var socket = io('http://' document.domain ':2120');

这个是服务端,但是'http://' document.domain ':2120'这个服务器要加什么文件?

另外:

这个后端是指以上3个文件的哪个地址?

后端调用api向任意用户推送:

<?php
// 指明给谁推送,为空表示向所有在线用户推送
$to_uid = "";
// 推送的url地址,使用自己的服务器地址
$push_api_url = "http://workerman.net:2121/";
$post_data = array(
   "type" => "publish",
   "content" => "这个是推送的测试数据",
   "to" => $to_uid, 
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $push_api_url );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data );
curl_setopt ($ch, CURLOPT_HTTPHEADER, array("Expect:"));
$return = curl_exec ( $ch );
curl_close ( $ch );
var_export($return);
?>
2584 1 0
1个回答

walkor

curl里$push_api_url = "http://workerman.net:2121/"; 改成实际服务器的ip或者域名,2121端口不变。

其它不用配置,直接运行就行。

  • 暂无评论
年代过于久远,无法发表回答
🔝