- api即url访问投递消息,在控制器的Index.php的index方法中写入如下代码:
~~~
//api消息,发送人uid,to接收人uid,content消息内容
event('swoole.websocket.Point', ['api' => true,'uid'=>$this->request->param('uid'), 'to' => $this->request->param('to'), 'content' => $this->request->param('content')]);
~~~
think-swoole的所有操作均可以用事件去完成.并且以`swoole.`开头.websocket事件均以`swoole.websocket.`开头.末尾跟上事件名称例如Point触发的就是onPoint事件.