sevent资料
https://github.com/melbahja/Sevent
开发参考
public function sevent($type = 'session_list', $param = '')
{
if (!$this->request->isAjax()) {
$this->redirect('User/Message/session');
}
$event = new \Common\Util\Sevent();
$ret = $event->response(function () use ($event, $type, $param) {
switch ($type) {
case 'session_list':
$session = $this->session();
$event->session_list(json_encode($session, JSON_NUMERIC_CHECK));
break;
case 'session_view':
parse_str($param);
$last_id = I('param.last_id');
$session = $this->get_new($uid, 1, $last_id);
$event->session_view(json_encode($session, JSON_NUMERIC_CHECK));
break;
case 'info_unread':
$map['status'] = 1;
$map['to_uid'] = $this->admin_uid;
$map['is_read'] = 0;
$map['type'] = 1;
$unread = M('user_message')->where($map)->count();
$event->info_unread(json_encode(['unread' => $unread], JSON_NUMERIC_CHECK));
break;
default:
break;
}
// conditions and code here
// $event->message('hello world'.$type); // sent a response message
});
return Response::create($ret, '', 200, $event->eventHeaders);
}