response($this->error([$e->getFile(),$e->getLine(),$e->getMessage()], '推送服务未开启,请联系管理员')); } /** * 绑定 */ public function bind() { $client_id = $this->params['client_id'] ?? ''; if(empty($client_id)){ return $this->response($this->error(null, '客户端id不能为空')); } try{ $this->initGateway(); Gateway::bindUid($client_id, $this->getUid($this->store_id)); return $this->response($this->success()); }catch(\Exception $e){ return $this->pushError($e); } } /** * 改变绑定 */ public function changeBind() { $client_id = $this->params['client_id'] ?? ''; $old_store_id = $this->params['old_store_id'] ?? ''; if(empty($client_id)){ return $this->response($this->error(null, '客户端id不能为空')); } try{ $this->initGateway(); Gateway::unbindUid($client_id, $this->getUid($old_store_id)); Gateway::bindUid($client_id, $this->getUid($this->store_id)); return $this->response($this->success()); }catch(\Exception $e){ return $this->pushError($e); } } /** * 下线 */ public function offline() { $client_id = $this->params['client_id'] ?? ''; if(empty($client_id)){ return $this->response($this->error(null, '客户端id不能为空')); } try{ $this->initGateway(); Gateway::closeClient($client_id); return $this->response($this->success()); }catch(\Exception $e){ return $this->pushError($e); } } /** * 服务状态 */ public function status() { try{ $this->initGateway(); Gateway::isUidOnline($this->getUid($this->store_id)); return $this->response($this->success()); }catch(\Exception $e){ return $this->pushError($e); } } }