12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\common\library;
- use \GatewayClient\Gateway;
- /**
- * gateway绑定接口
- */
- class GatewayworkerTools
- {
- /**
- * 直播间中发送大礼物,全服通告
- */
- public static function sendBigGiftInParty($sender, $receiver, $partyInfo, $giftUserParty)
- {
- $messageData = [
- 'type' => 'bigGiftNotice',
- 'data' => [
- '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'],
- 'value' => $giftUserParty['value'],
- ]
- ]
- ];
- $Gateway = new Gateway();
- $Gateway::$registerAddress = '127.0.0.1:2345';
- $Gateway::sendToAll(json_encode($messageData));
- }
- /**
- * 直播间中发送礼物,本房间飘屏
- */
- 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);
- }
|