Skip to content

Commit

Permalink
Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
xuas committed Aug 27, 2019
1 parent 9bf3b53 commit ebcdef2
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 48 deletions.
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ nohup ./videoRecServer > videoRecServer.log 2>&1 &

请注意该服务仅供内网其他服务使用,不要将19922端口暴露到外网!


```java
push系统消息:
toUsers:需要发送消息的所有用户,用逗号隔开
Expand All @@ -118,32 +117,28 @@ http://www.xxx.com:19922/pushGroupMsg?groupId=xxx&msg=xxxx

下面五个和群有关的接口,在客户端sdk同样有实现,但通过这些接口,服务端可以主动给群服务器同步群成员,或对群成员进行其他操作,请您根据实际需求来选取合适的群成员同步策略。
```java
同步时不传groupList表示清空这个群的成员
同步群成员:
groupId: 要同步的群id
groupList: 要同步的群内部的所有用户id,用逗号隔开
ignoreList: 设置过消息免打扰的素有用户id,用逗号隔开
groupId: 群id
groupList: 所有群成员,用逗号隔开,不传groupList表示清空这个群的成员
ignoreList: 对该群设置了消息免打扰的群成员id,用逗号隔开
http://www.xxx.com:19922/syncGroupList?groupId=xxx&groupList=userId1,userId2,userId3,...&ignoreList=userId1,userIdx,...

添加群好友:
groupId: 要操作的群id
添加群成员:
addedUsers: 要添加进的群的所有用户id,用逗号隔开
http://www.xxx.com:19922/addUsersToGroup?groupId=xxx&addedUsers=userId1,userId2,userId3,...

删除群好友:
groupId: 要操作的群id
删除群成员:
deledUsers: 需要从群内删除的所有用户id,用逗号隔开
http://www.xxx.com:19922/delUsersFromGroup?groupId=xxx&deledUsers=userId1,userId2,userId3,...

设置免打扰:
groupId: 要操作的群id
ignoreList: 需要从针对改群添加免打扰的所有用户id,用逗号隔开
ignoreList: 对该群设置消息免打扰(不接收群消息)的所有用户id,用逗号隔开
http://www.xxx.com:19922/setPushIgnore?groupId=xxx&ignoreList=userId1,userIdx,...

取消免打扰:
groupId: 要操作的群id
ignoreList: 需要从针对改群取消免打扰的所有用户id,用逗号隔开
ignoreList: 对该群取消免打扰(接收群消息)的所有用户id,用逗号隔开
http://www.xxx.com:19922/unsetPushIgnore?groupId=xxx&ignoreList=userId1,userIdx,...

```


Expand Down
2 changes: 1 addition & 1 deletion server-api/server-api-php/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function_exists("date_default_timezone_set")?date_default_timezone_set("Asia/Sha
define('password', 'password');


define('doc_upload_url', 'https://123.103.93.74/aec/uploads/');# 文档的访问url
define('doc_upload_url', 'https://www.starrtc.com/aec/uploads/');# 文档的访问url
Expand Down
3 changes: 0 additions & 3 deletions server-api/server-api-php/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@






30 changes: 23 additions & 7 deletions server-api/server-api-php/doc/convert_doc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

logf('get_doc_to_process');

//logf(exec("whoami", $arr));


$ret = get_doc();
if($ret['ret'] != 0){
echo 'get_doc_failed:'.$ret['ret'].'\r\n';
Expand Down Expand Up @@ -45,11 +48,12 @@

$cmd = 'convert -density 300 -trim '.$full_path . '[0-4] -quality 100 '. $dest_full_path . '/starRTC.jpg';
echo "cmd=$cmd \r\n";
logf($cmd);
exec($cmd);


$dest_file = $dest_full_path.'/starRTC-1.jpg';
if (file_exists($dest_file)){//检测文件是否存在
$dest_file = $dest_full_path.'/starRTC-1.jpg';
$single_file = $dest_full_path.'/starRTC.jpg';//只有一张图片时文件名为starRTC.jpg
if (file_exists($dest_file) || file_exists($single_file)){//检测文件是否存在
$ret = update_doc_convert_state($doc_id, convert_success);
if($ret != 0){
echo "update_state_to_success,error:$ret \r\n";
Expand All @@ -63,29 +67,41 @@
}
echo "failed1 \r\n";
}
}elseif(!strcasecmp($file_ext, 'pptx')){
}elseif(!strcasecmp($file_ext, 'pptx') || !strcasecmp($file_ext, 'ppt')){
$dest_full_path = $local_path . $doc_id;
if (!file_exists($dest_full_path)){
if(!mkdir($dest_full_path, 0777, true)){
echo "dir_create_failed \r\n";
}
}
//ppt转pdf
$cmd = "soffice --convert-to pdf:writer_pdf_Export --outdir $dest_full_path $full_path"; //生成在什么目录了,删除pdf
//$cmd = "soffice --convert-to pdf:writer_pdf_Export --outdir $dest_full_path $full_path";
$cmd = "/opt/libreoffice6.0/program/soffice --convert-to pdf:writer_pdf_Export --outdir $dest_full_path $full_path";
echo "cmd=$cmd \r\n";
logf($cmd);
exec($cmd);


$fileArr = pathinfo($doc_name);
$pdf_file = $dest_full_path.'/'.$fileArr['filename'].'.pdf';

//pdf转图片
$cmd = 'convert -density 300 -trim '.$pdf_file . '[0-4] -quality 100 '. $dest_full_path . '/starRTC.jpg';
echo "cmd=$cmd \r\n";
logf($cmd);
exec($cmd);

//删除pdf
if(file_exists($pdf_file)){
if (!unlink($pdf_file )){
echo "Error deleting $pdf_file";
}
logf('pdf deleted');
}

$dest_file = $dest_full_path.'/starRTC-1.jpg';
if (file_exists($dest_file)){//检测文件是否存在
$dest_file = $dest_full_path.'/starRTC-1.jpg';
$single_file = $dest_full_path.'/starRTC.jpg';//只有一张图片时文件名为starRTC.jpg
if (file_exists($dest_file) || file_exists($single_file)){//检测文件是否存在
$ret = update_doc_convert_state($doc_id, convert_success);
if($ret != 0){
echo "update_state_to_success,error:$ret \r\n";
Expand Down
15 changes: 9 additions & 6 deletions server-api/server-api-php/doc/get_doc_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@
$full_path = $local_path . $doc_id;
$count = count(glob($full_path . '/*.jpg'));
if($count == 0){
echoErr('process error');
echoErr("$id:process error");
}

$info = array();
$index = 0;
for($i=0; $i<$count; $i++){
$info[$index++] = $http_path . '/starRTC-' . $i . '.jpg';
}
if($count == 1){//只有一张图片时文件名为starRTC.jpg
$info[$index++] = $http_path . '/starRTC.jpg';
}else{
for($i=0; $i<$count; $i++){
$info[$index++] = $http_path . '/starRTC-' . $i . '.jpg';
}
}
echoK($info);
}elseif($state == convert_failed){
echoErr('process error');
echoErr("$id:process error:convert_failed");
}else{
echoErr('processing');
}
11 changes: 9 additions & 2 deletions server-api/server-api-php/eventCenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
require_once($aec_dir . '/include/group_join.php');
require_once($aec_dir . '/include/group_quit.php');
require_once($aec_dir . '/include/channel.php');
require_once($aec_dir . '/include/user.php');

$data = array_key_exists('data', $_REQUEST) ? $_REQUEST['data'] : 0;//接收服务端程序传过来的数据
if(empty($data)){
Expand All @@ -38,6 +39,9 @@





save_online_user($dataArr);
process_voip_event($action, $dataArr);
process_chatroom_event($action, $dataArr);
process_group_event($action, $dataArr);
Expand All @@ -50,7 +54,10 @@




function save_online_user($dataArr){//记录在线用户
$userId = array_key_exists('userId', $dataArr) ? $dataArr['userId'] : 0;
_save_online_user($userId);
}



Expand All @@ -59,7 +66,7 @@
//=========================VOIP(一对一)事件通知==================
//https://docs.starrtc.com/zh-cn/docs/aec-voip.html
function process_voip_event($action, $dataArr){
$userId = array_key_exists('userId', $dataArr) ? $dataArr['userId'] : 0;
$userId = array_key_exists('userId', $dataArr) ? $dataArr['userId'] : 0;

if(!strcasecmp($action, 'AEC_VOIP_USER_ONLINE')){//申请voip通话
//TODO: 可检查用户余额是否足够
Expand Down
3 changes: 1 addition & 2 deletions server-api/server-api-php/include/pubFun.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ function logf($data){
$fp = fopen(log_file, "a+");//读写方式打开,将文件指针指向文件末尾。如果文件不存在则尝试创建之。
$time = date('Y-m-d H:i:s');
fwrite($fp, $time.' '.$data."\r\n");//记得a+w
fclose($fp);

fclose($fp);
}


Expand Down
4 changes: 2 additions & 2 deletions server-api/server-api-php/include/star_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@


//push系统消息
function pushSystemMsgToUsers($msg, $digest, $users){
function pushSystemMsgToUsers($msg, $digest, $toUsers){
$url = proxyUrl.'pushSystemMsgToUsers';
$data = array (
'msg' => $msg,
'digest' => $digest, //摘要
'toUsers' => $users // 用户,用逗号隔开
'toUsers' => $toUsers // 用户,用逗号隔开
);

$ret = curl_post($url, $data);// 成功返回的是json {"status":"1"}
Expand Down
92 changes: 92 additions & 0 deletions server-api/server-api-php/include/user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php





function _save_online_user($userId){
global $g_writeMdb;
try{
$sql = "select id from online_users where userId = ? limit 1";
if(!($pstmt = $g_writeMdb->prepare($sql))){
return 13;
}
if($pstmt->execute(array($userId))){
$result = $pstmt->fetchAll();
$resNum = count($result);
$ctime = time();
if($resNum == 0){
$sql = "insert into online_users (userId, last_online_ts) values (?,?)";
if(!($pstmt = $g_writeMdb->prepare($sql))){
return 18;
}
if($pstmt->execute(array($userId, $ctime))){
return 0;
}else{
return 19;
}
}else{
$id = intval($result[0][0]);
$sql = "update `online_users` set last_online_ts = ? where `id` = ? limit 1";
if(!($pstmt = $g_writeMdb->prepare($sql))){
return 16;
}
if($pstmt->execute(array($ctime, $id))){
return 0;
}else{
return 17;
}
}
}else{
return 14;
}
}catch(PDOException $e){
return 11;
}
return 10;
}

//返回0表示在线
function is_user_online($userId){
global $g_writeMdb;
try{
$sql = "select id, last_online_ts from online_users where userId = ? limit 1";
if(!($pstmt = $g_writeMdb->prepare($sql))){
return 13;
}
if($pstmt->execute(array($userId))){
$result = $pstmt->fetchAll();
$resNum = count($result);
if($resNum == 0){
return 20;
}
$id = intval($result[0][0]);
$db_ts = $result[0][1];

$cur_ts = time();
$duration = $cur_ts - $db_ts; //s
if($duration < 60){//1min=60s 1分钟内认为在线
return 0;
}else{
logf("duration=$duration");
$sql = "delete from `online_users` where `id` = ? limit 1";
if(!($pstmt = $g_writeMdb->prepare($sql))){
return 16;
}
if($pstmt->execute(array($id))){
return 21;
}else{
return 17;
}
}
}else{
return 14;
}
}catch(PDOException $e){
return 11;
}
return 10;
}



8 changes: 6 additions & 2 deletions server-api/server-api-php/push_group_msg.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@



$groupId = array_key_exists('groupId', $_REQUEST) ? $_REQUEST['groupId'] : 0;
$contentData = array_key_exists('msg', $_REQUEST) ? $_REQUEST['msg'] : 0;
if(empty($groupId) ||empty($contentData)){
echoErr('missing args');
}



$groupId = 9;

$msgArr = array();
$msgArr['fromId'] = 'system'; //发送消息的人
Expand All @@ -17,7 +21,7 @@
$msgArr['msgIndex'] = $milliseconds; //消息编号
$msgArr['type'] = 1;
$msgArr['code'] = 0;
$msgArr['contentData'] = '群消息测试';
$msgArr['contentData'] = $contentData;
$msg = json_encode($msgArr);


Expand Down
12 changes: 9 additions & 3 deletions server-api/server-api-php/push_system_msg.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
require_once($dir . '/config.php');


$toUsers = array_key_exists('toUsers', $_REQUEST) ? $_REQUEST['toUsers'] : 0;//用户,用逗号隔开
$contentData = array_key_exists('msg', $_REQUEST) ? $_REQUEST['msg'] : 0;
if(empty($toUsers) ||empty($contentData)){
echoErr('missing args');
}



$msgArr = array();
Expand All @@ -13,13 +19,13 @@
$msgArr['msgIndex'] = $milliseconds; //消息编号
$msgArr['type'] = 1;
$msgArr['code'] = 0;
$msgArr['contentData'] = '系统消息测试';
$msgArr['contentData'] = $contentData;
$msg = json_encode($msgArr);


$digest ='您收到一条系统消息'; //摘要
$users = '524048'; // 用户,用逗号隔开
$ret = pushSystemMsgToUsers($msg, $digest, $users);
$ret = pushSystemMsgToUsers($msg, $digest, $toUsers);

$data = json_decode($ret, TRUE);
if($data['status'] != 1){
Expand Down
Loading

0 comments on commit ebcdef2

Please sign in to comment.