|
@@ -1,21 +1,51 @@
|
|
|
import { io } from "socket.io-client";
|
|
|
-const URL = process.env.URL || "http://127.0.0.1:3000";
|
|
|
-const MAX_CLIENTS = 10000;
|
|
|
+import customParser from "socket.io-msgpack-parser";
|
|
|
+const URL = process.env.URL || "wss://test-socket.4dkankan.com";
|
|
|
+
|
|
|
+const MAX_CLIENTS = 600;
|
|
|
const POLLING_PERCENTAGE = 0.05;
|
|
|
const CLIENT_CREATION_INTERVAL_IN_MS = 10;
|
|
|
const EMIT_INTERVAL_IN_MS = 1000;
|
|
|
-
|
|
|
+// wws://test-socket.4dkankan.com/watch
|
|
|
let clientCount = 0;
|
|
|
let lastReport = new Date().getTime();
|
|
|
let packetsSinceLastReport = 0;
|
|
|
+let testSceneNum = "t-test";
|
|
|
+let roomId = "00001";
|
|
|
+let userLimitNum = 2000;
|
|
|
+let agentId = 0;
|
|
|
+
|
|
|
+const createAgent = () => {
|
|
|
+ agentId += 1;
|
|
|
+ const nickName = `test_name_${agentId}`;
|
|
|
+ const userId = `6666666${agentId}`;
|
|
|
+ const role = agentId === 1 ? "leader" : "role";
|
|
|
+ createClient({ userId, nickName, from: '0', role });
|
|
|
+ createClient({ userId, nickName, from: '1', role });
|
|
|
+ createClient({ userId, nickName, from: '2', role });
|
|
|
+};
|
|
|
|
|
|
-const createClient = () => {
|
|
|
+const createClient = ({ userId, nickName, from, role }) => {
|
|
|
// for demonstration purposes, some clients stay stuck in HTTP long-polling
|
|
|
- const transports = Math.random() < POLLING_PERCENTAGE ? ["websocket"] : ["websocket", "websocket"];
|
|
|
|
|
|
const socket = io(URL, {
|
|
|
- path: "/test",
|
|
|
- transports,
|
|
|
+ path: "/fsl-node",
|
|
|
+ transport: ["websocket"],
|
|
|
+ parser: customParser,
|
|
|
+ query: {
|
|
|
+ userId: userId,
|
|
|
+ from: from || 2,
|
|
|
+ sceneNum: testSceneNum,
|
|
|
+ role: role,
|
|
|
+ nickName: nickName,
|
|
|
+ roomId: roomId,
|
|
|
+ voiceStatus: 0,
|
|
|
+ enableTalk: true,
|
|
|
+ isAuthMic: 0,
|
|
|
+ isAllowMic: 0,
|
|
|
+ userLimitNum,
|
|
|
+ myHeadUrl: "http://downza.img.zz314.com/edu/pc/wlgj-1008/2016-06-23/64ec0888b15773e3ba5b5f744b9df16c.jpg",
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
setInterval(() => {
|
|
@@ -31,11 +61,11 @@ const createClient = () => {
|
|
|
});
|
|
|
|
|
|
if (++clientCount < MAX_CLIENTS) {
|
|
|
- setTimeout(createClient, CLIENT_CREATION_INTERVAL_IN_MS);
|
|
|
+ setTimeout(createAgent, CLIENT_CREATION_INTERVAL_IN_MS);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-createClient();
|
|
|
+createAgent();
|
|
|
|
|
|
const printReport = () => {
|
|
|
const now = new Date().getTime();
|