swoole 学习小结

websocket_server.php

on("open",function (){
        echo '连接上了wjp';
    });
    //接受发送
    $server->on("message",function ($server,$frame){
       echo '收到消息wjp'.$frame->data,"\n";
       foreach($server->connections as $fd){
           $server->push($fd,$frame->data);
       }
    });
    //断开连接
    $server->on("close",function(){
        echo '断开连接wjp';
    });
//2启动服务器
 $server->start();

add.html=>发送推送信息




    
    
    
    
    Bootstrap 101 Template

    
    

    
    
    



添加推送消息

index.html  =>展示推送的消息




    
    
    
    
    Bootstrap 101 Template

    
    

    
    
    




 

 

你可能感兴趣的:(#,swoole)