Test.php 1.0 KB

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