root 1 year ago
parent
commit
f5f6c041ac
3 changed files with 15 additions and 5 deletions
  1. 1 1
      js/Office/Poll.js
  2. 2 1
      node/test.html
  3. 12 3
      node/test.js

+ 1 - 1
js/Office/Poll.js

@@ -270,5 +270,5 @@ U.MD.O.P.pollingAsyn = function (r) {
             }
         }
     }
-    U.MD.O.P.polling(); //进入轮循
+    //U.MD.O.P.polling(); //进入轮循
 }

+ 2 - 1
node/test.html

@@ -9,13 +9,14 @@
             var time = null;
             var xhr = new XMLHttpRequest();
             var data = "";
-            xhr.open("POST", "http://127.0.0.1:3000", true);
+            xhr.open("POST", "http://127.0.0.1:1473", true);
             xhr.onreadystatechange = function () {
                 if (xhr.readyState == 3 && xhr.status == 200) {
                     clearTimeout(time);
                     var len = xhr.responseText.length;
                     data += xhr.responseText.substring(start, len);
                     start = len;
+                    console.log(data)
                     time = setTimeout(function () {
                         clearTimeout(time);
                         data = "";

+ 12 - 3
node/test.js

@@ -5,6 +5,7 @@ us = {};
 // 引入Express模块
 const express = require('express');
 const path = require('path');
+us.http = require("http"); //引用http server服务
 // 创建Express应用
 const app = express();
 
@@ -12,9 +13,9 @@ const app = express();
 app.use(express.static(path.join(__dirname, '/')));
 
 
-
-// 定义路由
-app.all('/', (req, res) => {
+us.server = us.http.createServer(function (req, res) {
+    // 定义路由
+    // app.all('/', (req, res) => {
     //设置跨域
     res.writeHead(200, {
         "Content-Type": "application/json",
@@ -36,4 +37,12 @@ app.listen(3000, () => {
     console.log('Server is running on port 3000');
 });
 
+/**
+* 监听1473端口的处理
+*
+**/
+us.server.listen('1473', '', function () {
+    //在控制台输出监听提示
+    console.log("开始监听" + us.server.address().port + "......");
+});