Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问支持 https 站点么? socket 是否也支持 wss协议 #11

Closed
iMactool opened this issue Jul 12, 2017 · 7 comments
Closed

请问支持 https 站点么? socket 是否也支持 wss协议 #11

iMactool opened this issue Jul 12, 2017 · 7 comments
Labels

Comments

@iMactool
Copy link

请问支持 https 站点么? socket 是否也支持 wss协议

@walkor
Copy link
Owner

walkor commented Jul 12, 2017

支持。
参考phpsocket.io手册
https://github.com/walkor/phpsocket.io/tree/master/docs/zh#支持sslhttps-wss

@iMactool
Copy link
Author

Worker好像不支持 https协议 ? http://doc.workerman.net/315128
image
只有http请求可以通过(因为整站都是https的,如果worker 用 http 会不会有什么影响么?)。
image

@walkor
Copy link
Owner

walkor commented Jul 14, 2017

Worker支持https,参考workerman手册 http://doc.workerman.net/315298

@iMactool
Copy link
Author

感谢抽空回复。

@iMactool
Copy link
Author

iMactool commented Jul 15, 2017

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

<?php
// 指明给谁推送,为空表示向所有在线用户推送
$to_uid = "";
// 推送的url地址,使用自己的服务器地址
$push_api_url = "http://workerman.net:2121/";
$post_data = array(
   "type" => "publish",
   "content" => "这个是推送的测试数据",
   "to" => $to_uid, 
);

这里 "to" => $to_uid, 只能接收 一个uid的值 ?如果要发送给多个人尼? 而且好像($_POST)只能发送和接收 type,content,to这三个值 如果自己增加几个参数怎么办?。

$post_data = array(
  "type" => "publish",
  "content" => "这个是推送的测试数据",
  "to" => $to_uid, 
  "other1"=>'xx',
  "other2"=>'sss'
);

@walkor
Copy link
Owner

walkor commented Jul 15, 2017

可以传多个,自己foreach 发就行了。
你这个问题自己稍微改下代码就ok了

@iMactool
Copy link
Author

发送多人的 foreach 了

if(is_array($to)){
	 foreach ($to as $toid){
		 $io->to($toid)->emit('new msg',$_POST['content']);
	 }
	 }else{
	     $io->to($to)->emit('new msg',$_POST['content']);
	 }

,这个多添加的参数没找到在哪个文件里修改。
直接用这样方式了
image

看着有点别扭 :(

@walkor walkor closed this as completed Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants