Index.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\index\controller;
  3. use app\common\controller\Frontend;
  4. use think\Db;
  5. class Index extends Frontend
  6. {
  7. protected $noNeedLogin = '*';
  8. protected $noNeedRight = '*';
  9. protected $layout = '';
  10. public function testredis(){
  11. $list = Db::name('user')->column('id');
  12. foreach($list as $key => $id){
  13. dump($id.':'.redis_matching_get($id));
  14. $a = redis_matching_set($id,0);
  15. }
  16. exit;
  17. }
  18. public function test1(){
  19. // 文本加一个回车
  20. $buffer1 = 'abcdefghijklmn';
  21. // 在php中双引号中的\n代表一个换行符,例如"\n"
  22. $buffer2 = '{"type":"say", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello", "content":"hello"}'."";
  23. $buffer2 = 'abcdefghijklmn'."\n";
  24. // 与服务端建立socket连接
  25. $client = stream_socket_client('tcp://1.14.197.70:2349');
  26. // 以text协议发送buffer1数据
  27. //fwrite($client, $buffer1);
  28. // 以text协议发送buffer2数据
  29. fwrite($client, $buffer2);
  30. }
  31. public function index()
  32. {
  33. return $this->view->fetch();
  34. }
  35. }