- 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事件.