access_client.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/12/24
  6. * Time: 下午1:05
  7. */
  8. namespace room;
  9. use search\tcp_client;
  10. class access_client extends tcp_client
  11. {
  12. protected static $stInstance;
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. $this->mBodyType = tcp_client::JsonType;
  17. }
  18. public static function instance()
  19. {
  20. if(self::$stInstance == null) {
  21. self::$stInstance = new factory_client();
  22. }
  23. return self::$stInstance;
  24. }
  25. public function __destruct()
  26. {
  27. parent::__destruct();
  28. }
  29. public function remote_addr()
  30. {
  31. global $config;
  32. $host = $config['room_srv']['host'];
  33. $port = $config['room_srv']['port'];
  34. return "{$host}:{$port}";
  35. }
  36. public function join($room,$room_key)
  37. {
  38. $param = ["act" => 'factory','op' => 'create', "type" => 'bargain_goods','params' => ['goods_id' => $goods_id,'user' => $user]];
  39. $result = $this->request($param);
  40. if(empty($result)) return false;
  41. $code = intval($result['code']);
  42. if($code != 200) {
  43. return false;
  44. }
  45. else {
  46. return true;
  47. }
  48. }
  49. }