app模板、应用模板、组件模板、widget模板
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

4 years ago
  1. var WebSocketServer = require('ws').Server,
  2. wss = new WebSocketServer({ port: 9999 });
  3. wss.on('connection', function (ws) {
  4. console.log('client connected');
  5. ws.on('message', function (message) {
  6. console.log(message);
  7. ws.send("服务端接收到请求后,发送给客户端的数据");
  8. });
  9. var i = 1;
  10. setInterval(function () {
  11. i++;
  12. ws.send(JSON.stringify(
  13. {
  14. payload:{
  15. message:{
  16. "id":i,
  17. "appName": "qwer",
  18. "text": "我是一条推送测试"+i,
  19. "type": "数据指挥",
  20. "level":1,
  21. "compnent":1,
  22. "time": 1622972899706,
  23. "title":"张三",
  24. "reply":1,
  25. "extra":{
  26. "text":"这是一条附加信息"
  27. }
  28. },
  29. msgType:"SILENT_APP",//NONTIFY_APP 打开对应的App SILENT_APP 框架处理消息
  30. appId:"widget_demo_3"
  31. },
  32. type:"message"
  33. }
  34. ))
  35. }, 5000)
  36. })