想客戶(hù)連接進(jìn)來(lái)之后,就一直推送消息給客戶(hù)端。
onMessage 只能實(shí)現(xiàn)有消息時(shí)
onConnect的時(shí)候給鏈接加個(gè)定時(shí)器,定時(shí)發(fā)送數(shù)據(jù)給這個(gè)客戶(hù)端,onClose的時(shí)候關(guān)閉定時(shí)器。
或者onWorkerStart的時(shí)候添加一個(gè)全局的定時(shí)器,定時(shí)給某些或者某個(gè)客戶(hù)端發(fā)送數(shù)據(jù)。
也可以在需要的時(shí)機(jī)在其它項(xiàng)目中推送數(shù)據(jù)給客戶(hù)端。
手冊(cè)參考
http://doc3.workerman.net/worker-development/add.html
http://doc3.workerman.net/faq/send-data-to-client.html
http://doc3.workerman.net/faq/push-in-other-project.html
http://doc3.workerman.net/faq/how-to-broadcast.html
http://wtbis.cn/gatewaydoc/advanced/push.html