gemercheung 3 tahun lalu
induk
melakukan
832dad48ed

+ 65 - 9
packages/main/command/test.mjs

@@ -6,8 +6,17 @@ const count = process.argv[3];
 const userStartId = process.argv[4];
 const testSceneNum = process.argv[5] || "t-test";
 const roomId = process.argv[6] || "00001";
-
-console.log("argv", userStartId, testSceneNum, roomId);
+const isMockCamera = process.argv[7] || 0;
+const cameraInterval = process.argv[8] || 3000;
+let testCamera;
+console.log(
+  "argv:",
+  userStartId,
+  testSceneNum,
+  roomId,
+  isMockCamera,
+  cameraInterval
+);
 
 console.log("socket-info::url:config-->", url);
 console.log("socket-info::url:count-->", count);
@@ -15,9 +24,9 @@ console.log("socket-info::start-->压力测试正在开始");
 const URL = url || process.env.URL;
 // http://zhang9394@zhangyupeng:face3d.4dage.com:7005/zhangyupeng/chatIM.git
 const MAX_CLIENTS = Number(count) || 500;
-const POLLING_PERCENTAGE = 0.05;
 const CLIENT_CREATION_INTERVAL_IN_MS = 10;
 const EMIT_INTERVAL_IN_MS = 1000;
+const EMIT_INTERVAL_IN_MS_camera = cameraInterval;
 // wws://test-socket.4dkankan.com/watch
 let clientCount = 0;
 let lastReport = new Date().getTime();
@@ -31,19 +40,23 @@ const createAgent = () => {
   agentId += 1;
   const nickName = `test_name_${userStartId}${agentId}`;
   const userId = `${userStartId}${agentId}`;
+  const oid = `oid-${userStartId}${agentId}`;
   const role = agentId === 1 ? "leader" : "customer";
-  createClient({ userId, nickName, from: "0", role: role });
-  createClient({ userId, nickName, from: "1", role: role });
-  createClient({ userId, nickName, from: "2", role: role });
+  createClient({ userId, nickName, from: "0", role: role, oid });
+  createClient({ userId, nickName, from: "1", role: role, oid });
+  createClient({ userId, nickName, from: "2", role: role, oid });
 };
 
-const createClient = ({ userId, nickName, from, role }) => {
+const createClient = ({ userId, nickName, from, role, oid }) => {
   // for demonstration purposes, some clients stay stuck in HTTP long-polling
 
   const socket = io(URL, {
     path: "/fsl-node",
-    transport: ["websocket"],
+    transports: ["websocket"],
     parser: customParser,
+    extraHeaders: {
+      oid: oid,
+    },
     query: {
       userId: userId,
       from: from || 2,
@@ -61,10 +74,51 @@ const createClient = ({ userId, nickName, from, role }) => {
     },
   });
 
+  if (Number(isMockCamera) === 1) {
+    setInterval(() => {
+      const data = {
+        testUserId: userId,
+        item: {
+          qua: {
+            _x: -0.11495106988815072,
+            _y: 0.13408027376477993,
+            _z: 0.015660797097947755,
+            _w: 0.9841562229407423,
+          },
+          mode: "panorama",
+          pos: {
+            x: 1.7477431297302246,
+            y: -0.1338435709476471,
+            z: 1.3797638416290283,
+          },
+          type: "Rotate",
+          pano: "1",
+          target: {
+            x: 1.4874317088952322,
+            y: -0.3643028004004215,
+            z: 0.442146378191566,
+          },
+        },
+      };
+      socket.emit("client-benmark-server", data);
+    }, EMIT_INTERVAL_IN_MS_camera);
+  }
+
   setInterval(() => {
     socket.emit("client to server event");
   }, EMIT_INTERVAL_IN_MS);
 
+  socket.on("server-benmark-client", (data) => {
+    packetsSinceLastReport++;
+    testCamera = data;
+    // console.log("客户端收到服务端-镜头-MOCK", data);
+  });
+
+  // socket.emit("server-interval-room-broadcast", { time: 1000 });
+  // socket.on("client-interval-room-broadcast", (data) => {
+  //   console.log(`客户端${userId}收到房间播报-MOCK"`, data);
+  // });
+
   socket.on("server to client event", () => {
     packetsSinceLastReport++;
   });
@@ -88,7 +142,9 @@ const printReport = () => {
   ).toFixed(2);
 
   console.log(
-    `client count: ${clientCount} ; average packets received per second: ${packetsPerSeconds}`
+    `client count: ${clientCount} ; average packets received per second: ${packetsPerSeconds} ${
+      testCamera ? " carmera:" + JSON.stringify(testCamera) : ""
+    }`
   );
 
   packetsSinceLastReport = 0;

+ 5 - 3
packages/main/src/mainWindow.ts

@@ -15,7 +15,7 @@ async function createWindow() {
   const browserWindow = new BrowserWindow({
     show: false, // Use 'ready-to-show' event to show window
     width: 750,
-    height: 600,
+    height: 700,
     resizable: false,
     autoHideMenuBar: true,
     webPreferences: {
@@ -43,6 +43,8 @@ async function createWindow() {
         count,
         userStartId,
         testSceneNum,
+        isMockCamera,
+        cameraInterval,
         roomId, stop } = data;
       if (stop) {
         try {
@@ -69,8 +71,8 @@ async function createWindow() {
         const nodePath = app.isPackaged ? nodePathProduction : 'node';
 
         // browserWindow.webContents.send('terminal.resourcesPath', app.isPackaged);
-        ptyProcess = pty.spawn(shell, [`${nodePath} ${BenmarkFilePath}`, `${url}`, `${count}`, 
-        `${userStartId}`, `${testSceneNum}`, `${roomId}`], {
+        ptyProcess = pty.spawn(shell, [`${nodePath} ${BenmarkFilePath}`, `${url}`, `${count}`,
+        `${userStartId}`, `${testSceneNum}`, `${roomId}`, `${isMockCamera}`, `${cameraInterval}`], {
           name: 'xterm-color',
           cols: 80,
           rows: 30,

+ 23 - 0
packages/renderer/src/App.vue

@@ -12,6 +12,8 @@ const config = ref({
   userStartId: '6666666',
   testSceneNum: 't-test',
   roomId: '00001',
+  isMockCamera: '0',
+  cameraInterval: 10000,
   isStart: false,
 });
 let terminal: Terminal | null;
@@ -48,6 +50,8 @@ function start() {
     userStartId: config.value.userStartId,
     testSceneNum: config.value.testSceneNum,
     roomId: config.value.roomId,
+    isMockCamera: config.value.isMockCamera,
+    cameraInterval: config.value.cameraInterval,
   });
 }
 function stop() {
@@ -85,6 +89,21 @@ function stop() {
       <span class="label">测试房间号:</span>
       <input v-model="config.roomId">
     </figure>
+    <figure>
+      <span class="label">是否开启发送镜头数据:</span>
+      <select v-model="config.isMockCamera">
+        <option value="1">
+          是
+        </option>
+        <option value="0">
+          否
+        </option>
+      </select>
+    </figure>
+    <figure>
+      <span class="label">镜头数据间隔:</span>
+      <input v-model="config.cameraInterval">
+    </figure>
   </fieldset>
 
   <div class="btns">
@@ -124,6 +143,10 @@ fieldset .label {
   min-width: 120px;
   display: inline-block;
 }
+fieldset select {
+  width: 120px;
+  display: inline-block;
+}
 .btns {
   margin-bottom: 15px;
 }