diff --git a/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj b/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj
index 1481ede..ce8f2c7 100644
--- a/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj
+++ b/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj
@@ -16,7 +16,12 @@
+
+
+
+
+
diff --git a/src/ZonyLrcTools.LocalServer/Program.cs b/src/ZonyLrcTools.LocalServer/Program.cs
index 9144d52..1f02925 100644
--- a/src/ZonyLrcTools.LocalServer/Program.cs
+++ b/src/ZonyLrcTools.LocalServer/Program.cs
@@ -30,7 +30,7 @@ WebApplication? RegisterAndConfigureServices()
insideApp.UseAuthorization();
insideApp.MapControllers();
- insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser);
+ // insideApp.Lifetime.ApplicationStarted.Register(OpenBrowser);
return insideApp;
}
diff --git a/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs b/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs
index 72c69fd..d919612 100644
--- a/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs
+++ b/src/ZonyLrcTools.LocalServer/SuperSocketListener.cs
@@ -1,4 +1,5 @@
-using SuperSocket.WebSocket.Server;
+using Newtonsoft.Json;
+using SuperSocket.WebSocket.Server;
namespace ZonyLrcTools.LocalServer;
@@ -7,9 +8,65 @@ public class SuperSocketListener
public async Task ListenAsync()
{
var host = WebSocketHostBuilder.Create()
- .UseWebSocketMessageHandler(async (session, message) => { await session.SendAsync(message.Message); })
+ .UseWebSocketMessageHandler(async (session, message) =>
+ {
+ await session.SendAsync(JsonConvert.SerializeObject(new CommunicateEvent
+ {
+ Action = "output",
+ Type = ActionType.ResponseAction,
+ Data = new OutputEvent()
+ }));
+
+ for (int index = 0; index < 50; index++)
+ {
+ var data = new List();
+ for (int j = 0; j < 500; j++)
+ {
+ data.Add(new GetFileInfoEvent
+ {
+ Name = j.ToString(),
+ Size = j.ToString()
+ });
+ }
+
+ await session.SendAsync(JsonConvert.SerializeObject(new CommunicateEvent>
+ {
+ Action = "getFileInfo",
+ Type = ActionType.ResponseAction,
+ Data = data
+ }));
+ }
+
+ await Task.Delay(100);
+ })
.Build();
await host.StartAsync();
}
+}
+
+public class CommunicateEvent where T : class
+{
+ [JsonProperty("action")] public string? Action { get; set; }
+
+ [JsonProperty("type")] public ActionType Type { get; set; }
+
+ [JsonProperty("data")] public T? Data { get; set; }
+}
+
+public class OutputEvent
+{
+ [JsonProperty("text")] public string Text => DateTime.Now.ToString("HH:mm:ss");
+}
+
+public class GetFileInfoEvent
+{
+ [JsonProperty("name")] public string Name { get; set; }
+ [JsonProperty("size")] public string Size { get; set; }
+}
+
+public enum ActionType
+{
+ RequestAction,
+ ResponseAction
}
\ No newline at end of file
diff --git a/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj b/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj
index 93a17c5..c801246 100644
--- a/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj
+++ b/src/ZonyLrcTools.LocalServer/ZonyLrcTools.LocalServer.csproj
@@ -25,6 +25,10 @@
+
+
+
+
diff --git a/src/ui/src/communication/eventbus.js b/src/ui/src/communication/eventbus.js
new file mode 100644
index 0000000..41600c9
--- /dev/null
+++ b/src/ui/src/communication/eventbus.js
@@ -0,0 +1,5 @@
+import Vue from "vue";
+
+const eventBus = new Vue();
+
+export default eventBus;
\ No newline at end of file
diff --git a/src/ui/src/communication/socket.js b/src/ui/src/communication/socket.js
index 74f4735..1e3e884 100644
--- a/src/ui/src/communication/socket.js
+++ b/src/ui/src/communication/socket.js
@@ -1,4 +1,5 @@
import Vue from 'vue'
+import eventBus from "@/communication/eventbus";
// const wsUrl = process.env.VUE_APP_WS_URL;
const wsUrl = "ws://127.0.0.1:50001"
@@ -13,10 +14,11 @@ const emitter = new Vue({
}, connect() {
socket = new WebSocket(wsUrl);
socket.onmessage = (msg) => {
- this.$emit('message', msg.data);
+ let event = JSON.parse(msg.data);
+ eventBus.$emit(event.action, event);
};
socket.onerror = (err) => {
- this.$emit('error', err);
+ eventBus.$emit('error', err);
};
socket.onclose = () => {
emitter.connect()
diff --git a/src/ui/src/store/index.js b/src/ui/src/store/index.js
index 55c95b8..542aa5c 100644
--- a/src/ui/src/store/index.js
+++ b/src/ui/src/store/index.js
@@ -1,6 +1,5 @@
import Vue from 'vue'
import Vuex from 'vuex'
-import ws from './ws'
Vue.use(Vuex)
@@ -9,5 +8,5 @@ export default new Vuex.Store({
getters: {},
mutations: {},
actions: {},
- modules: {ws}
+ modules: {}
})
diff --git a/src/ui/src/store/ws.js b/src/ui/src/store/ws.js
deleted file mode 100644
index 9cdf031..0000000
--- a/src/ui/src/store/ws.js
+++ /dev/null
@@ -1,21 +0,0 @@
-export const state = {
- wsRes: {}
-};
-
-export const actions = {};
-
-export const mutations = {
- setWsRes(newState, payload) {
- state.wsRes = payload;
- }
-};
-
-export const getters = {};
-
-export default {
- state,
- actions,
- mutations,
- getters,
- namespaced: true
-}
\ No newline at end of file
diff --git a/src/ui/src/views/HomeView.vue b/src/ui/src/views/HomeView.vue
index a2a4e2f..4da528b 100644
--- a/src/ui/src/views/HomeView.vue
+++ b/src/ui/src/views/HomeView.vue
@@ -21,15 +21,15 @@
-
+