141 lines
2.7 KiB
PHP
141 lines
2.7 KiB
PHP
<?php
|
|
namespace server\modules\api\service;
|
|
use server\modules\api\controller\ChatLogic;
|
|
use server\components\ApiException;
|
|
|
|
class Service {
|
|
|
|
/**
|
|
* 定义服务对象.
|
|
*
|
|
* @var
|
|
*/
|
|
private static $_service;
|
|
|
|
/**
|
|
* 初始化.
|
|
*
|
|
* @param array $param
|
|
*/
|
|
public function __construct($param){
|
|
self::$_service = new ChatLogic($param);
|
|
}
|
|
|
|
/**
|
|
* 重连,断线时调.
|
|
*/
|
|
public function actionReConnect(){
|
|
try{
|
|
|
|
self::$_service->reConnect();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 客服初始链接
|
|
*/
|
|
public function actionInit(){
|
|
|
|
try{
|
|
self::$_service->init();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 用户初始链接
|
|
*/
|
|
public function actionUserInit(){
|
|
|
|
try{
|
|
self::$_service->userInit();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 聊天信息处理
|
|
*/
|
|
public function actionChat(){
|
|
|
|
try{
|
|
self::$_service->chat();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 回执信息处理
|
|
*/
|
|
public function actionSendReceiptMsg(){
|
|
|
|
try{
|
|
self::$_service->sendReceiptMsg();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 切换客服组
|
|
*/
|
|
public function actionChangeGroup(){
|
|
|
|
try{
|
|
self::$_service->changeGroup();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 关闭连接
|
|
*/
|
|
public function actionClose(){
|
|
|
|
try{
|
|
self::$_service->close();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 检测重复登录
|
|
*/
|
|
public function actionCheckRepetitionLine(){
|
|
|
|
try{
|
|
self::$_service->checkRepetitionLine();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 关闭重复登录
|
|
*/
|
|
public function actionCloseRepetitionLine(){
|
|
|
|
try{
|
|
self::$_service->closeRepetitionLine();
|
|
|
|
}catch (ApiException $e){
|
|
throw new ApiException($e->getCode(),$e->getMessage());
|
|
}
|
|
}
|
|
|
|
} |