feat(socket): 实现 WebSocket 代理功能
- 新增 WebSocket 中间件,支持连接到指定端口的 TCP 服务器 - 在 ServerEvent 中添加错误日志输出 - 优化 ClientData 解析逻辑,增加类型断言 - 更新 index.html,添加 socket 代理配置
This commit is contained in:
@@ -23,19 +23,52 @@
|
||||
flex-shrink: 0; /* 防止播放器被压缩 */
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
}
|
||||
:root {
|
||||
--logo-display: block; /* 默认值,可以是 inline, flex, none 等 */
|
||||
--logo-width: 150px; /* Logo 宽度 */
|
||||
--logo-height: auto; /* Logo 高度,保持比例 */
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<div id="container" style="--logo-display: none; --splash-screen-background:rgb(97,171,245)"></div>
|
||||
<script src="//unpkg.com/@ruffle-rs/ruffle"></script>
|
||||
<script>
|
||||
function generateAllPortsProxy(host, baseUrl = "ws://localhost:8080/ws/?port=") {
|
||||
// 生成1-65535范围内的所有端口配置
|
||||
const socketProxy = [];
|
||||
|
||||
for (let port = 1; port <= 65535; port++) {
|
||||
socketProxy.push({
|
||||
host: host,
|
||||
port: port,
|
||||
proxyUrl: `${baseUrl}${port}`
|
||||
});
|
||||
}
|
||||
|
||||
return socketProxy;
|
||||
}
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
const ruffle = window.RufflePlayer.newest();
|
||||
const player = ruffle.createPlayer();
|
||||
const container = document.getElementById('container');
|
||||
container.appendChild(player);
|
||||
window.RufflePlayer.config = {
|
||||
"autoplay": "on",
|
||||
"contextMenu": "off",
|
||||
"numFrames":6,
|
||||
// "frameRate": 60,
|
||||
socketProxy: [
|
||||
{
|
||||
host: "127.0.0.1", // The address of the server that Flash tries to connect to
|
||||
port: 12345, // The port that Flash tries to connect to
|
||||
proxyUrl: "ws://localhost:8080/ws/0", // The actual proxy that Ruffle will connect to, instead of the above server
|
||||
}
|
||||
],
|
||||
fontSources: ["fonts/simsun.ttf","fonts/Tahoma.ttf"], // load up fonts here
|
||||
defaultFonts: {
|
||||
sans: ["simsun"], // then replace them here.
|
||||
@@ -46,6 +79,7 @@
|
||||
// japaneseMincho: ["font"],
|
||||
}
|
||||
}
|
||||
window.RufflePlayer.config.socketProxy = generateAllPortsProxy("127.0.0.1");
|
||||
player.load('Client.swf');
|
||||
});
|
||||
</script>
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user