dongshao8566 2017-05-01 05:21
浏览 51

使用棘轮websocket推送通知

I'm working with codeigniter, and ratchet websocket, I have set up codeigniter with ratchet well, but im having problems with logic, I have to do in codeigniter and ratchet, I want to send notifications to a specif user in my model , addNotification, checkForNotifications, getNotifications , ,removeUserNotifications, removeNotifications

if ($arr = getNotifications() > 0){
     //Mostrar en tabla $arr
     if $arr[0].type == UNREAD
         //mostar un icono adecuado para unread
     else if $arr[0].type == NEW
                 //mostar un icono adecuado para new
   else if $arr[0].type == VIEWED
                 //mostar un icono adecuado para viewd

}else{
   echo "No tienes notifications"
}

then send them

how can I do it?

public function websocket(){
        $entryData = array(
            'category' => $_POST['category'], 
            'title'    => $_POST['title'], 
            'article'  => $_POST['article'], 
            'when'     => time()
         );

        $context = new ZMQContext();
        $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
        $socket->connect("tcp://localhost:5555");
        $socket->send(json_encode($entryData));
    }

i need someone could help how can I do it dinamically without touch views, just controller and model because the own system will do it

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?