Test.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\index\controller;
  3. use think\Controller;
  4. use \GatewayWorker\Lib\Gateway;
  5. class Test extends Controller
  6. {
  7. public function test(){
  8. $Gateway = new Gateway();
  9. $Gateway::$registerAddress = '127.0.0.1:2345';
  10. $Gateway::sendToAll('来自服务端的主动推送'.date('Y-m-d H:i:s'));
  11. }
  12. public function ip(){
  13. $ipaddress = ip_to_address();
  14. echo $ipaddress;
  15. }
  16. public function newip(){
  17. $ipaddress = newip_to_address();
  18. echo $ipaddress;
  19. }
  20. public function test_redis(){
  21. $redis = new Redis();
  22. $redisconfig = config("redis");
  23. $redis->connect($redisconfig["host"], $redisconfig["port"]);
  24. if ($redisconfig['redis_pwd']) {
  25. $redis->auth($redisconfig['redis_pwd']);
  26. }
  27. if($redisconfig['redis_selectdb'] > 0){
  28. $redis->select($redisconfig['redis_selectdb']);
  29. }
  30. $party_id = 141;
  31. $res = $redis->hGetAll("online_".$party_id);
  32. dump($res);
  33. }
  34. }