123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/12/14
- * Time: 上午11:43
- */
- namespace room;
- use search\tcp_client;
- class factory_client extends tcp_client
- {
- protected static $stInstance;
- public function __construct()
- {
- parent::__construct();
- $this->mBodyType = tcp_client::JsonType;
- }
- public static function instance()
- {
- if(self::$stInstance == null) {
- self::$stInstance = new factory_client();
- }
- return self::$stInstance;
- }
- public function __destruct()
- {
- parent::__destruct();
- }
- public function remote_addr()
- {
- global $config;
- $host = $config['room_factory']['host'];
- $port = $config['room_factory']['port'];
- return "{$host}:{$port}";
- }
- public function create_bargain($goods_id,$user,$lowest_price,$usable_days,$random = true,$total_num = 10)
- {
- $random = $random ? 1 : 0;
- $param = ["act" => 'factory','op' => 'create', "type" => 'bargain_goods','creator' => $user,'goods_id' => $goods_id,
- 'lowest_price' => $lowest_price,'usable_days' => $usable_days,'random' => $random,'total_num' => $total_num];
- $result = $this->request($param);
- if(empty($result)) return false;
- $code = intval($result['code']);
- if($code != 200) {
- return false;
- }
- else {
- return $result['data'];
- }
- }
- public function create_chat($creator,$user)
- {
- $param = ["act" => 'factory','op' => 'create', "type" => 'chat','creator' => $creator,'user' => $user];
- $result = $this->request($param);
- if(empty($result)) return false;
- $code = intval($result['code']);
- if($code != 200) {
- return false;
- }
- else {
- return $result['data'];
- }
- }
- public function create_group($creator)
- {
- $param = ["act" => 'factory','op' => 'create', "type" => 'group','creator' => $creator];
- $result = $this->request($param);
- if(empty($result)) return false;
- $code = intval($result['code']);
- if($code != 200) {
- return false;
- }
- else {
- return $result['data'];
- }
- }
- public function create_shake($creator)
- {
- $param = ["act" => 'factory','op' => 'create', "type" => 'shake_bonus','creator' => $creator];
- $result = $this->request($param);
- if(empty($result)) return false;
- $code = intval($result['code']);
- if($code != 200) {
- return false;
- }
- else {
- return $result['data'];
- }
- }
- public function invite($roomid,$user)
- {
- $param = ["act" => 'factory','op' => 'invite','room' => $roomid,'user' => $user];
- $result = $this->request($param);
- if(empty($result)) return false;
- $code = intval($result['code']);
- if($code != 200) {
- return false;
- }
- else {
- return $result['data'];
- }
- }
- }
|