| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 | <?phpnamespace app\common\library;use think\Request;use GatewayClient\Gateway;require_once VENDOR_PATH . 'workerman/gatewayclient/Gateway.php';/** * gateway绑定接口 */class Gatewayworker{    public function __construct(Request $request = null)    {        parent::__construct($request);        $params_from = $this->request->request('params_from'); // 客户端        if ($params_from == "wxmin") {            Gateway::$registerAddress = "127.0.0.1:1239";        } else {            Gateway::$registerAddress = "127.0.0.1:1238";        }    }    /**     * 直播间中发送大礼物,全服通告     */    public static function sendBigGiftInParty($sender, $receiver, $partyInfo, $giftUserParty)    {        $aData = [            'code' => 'party',            'data' => [                'cmd'     => 'send_big_gift_in_party',                'content' => [                    'party_info'  => [                        'party_id'   => $partyInfo['id'],                        'room_type'  => $partyInfo['room_type'],                        'party_name' => $partyInfo['party_name']                    ],                    'notice_info' => [                        'sender'     => $sender,                        'receiver'   => $receiver,                        'gift_num'   => $giftUserParty['number'],                        'gift_name'  => $giftUserParty['gift_name'],                        'gift_image' => $giftUserParty['gift_gif_image']                    ]                ]            ]        ];        dump($aData);        Gateway::sendToAll(json_encode($aData));    }    /**     * 直播间中发送礼物,本房间飘屏     */    public static function sendGiftInParty($sender, $receiver, $partyInfo, $giftUserParty)    {        $aData = [            'code' => 'party',            'data' => [                'cmd'     => 'send_gift_in_party',                'content' => [                    'party_info'  => [                        'party_id'   => $partyInfo['id'],                        'room_type'  => $partyInfo['room_type'],                        'party_name' => $partyInfo['party_name']                    ],                    'notice_info' => [                        'sender'     => $sender,                        'receiver'   => $receiver,                        'gift_num'   => $giftUserParty['number'],                        'gift_name'  => $giftUserParty['gift_name'],                        'gift_image' => $giftUserParty['gift_gif_image']                    ]                ]            ]        ];        Gateway::sendToGroup($partyInfo['id'],json_encode($aData));    }    // 注意除了不支持sendToCurrentClient和closeCurrentClient方法//        Gateway::sendToAll($data);//        Gateway::sendToClient($client_id, $data);//        Gateway::closeClient($client_id);//        Gateway::isOnline($client_id);//        Gateway::bindUid($client_id, $uid);//        Gateway::isUidOnline($uid);//        Gateway::getClientIdByUid($uid);//        Gateway::unbindUid($client_id, $uid);//        Gateway::sendToUid($uid, $data);//        Gateway::joinGroup($client_id, $group);//        Gateway::sendToGroup($group, $data);//        Gateway::leaveGroup($client_id, $group);//        Gateway::getClientCountByGroup($group);//        Gateway::getClientSessionsByGroup($group);//        Gateway::getAllClientCount();//        Gateway::getAllClientSessions();//        Gateway::setSession($client_id, $session);//        Gateway::updateSession($client_id, $session);//        Gateway::getSession($client_id);}
 |