Skip to content

Commit 851f805

Browse files
Add dispatch methods for the events
1 parent b1e2e89 commit 851f805

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

frontend/src/services/socketClient.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { io } from "socket.io-client";
22
import config from "../../public/config";
3+
import store from "../store";
34

45
// Shared Socket.IO client for the Vue app
56
// Uses same apiurl as the existing frontend config
@@ -8,4 +9,41 @@ const socket = io(config.apiurl, {
89
withCredentials: true,
910
});
1011

12+
// Recreate vue-socket-io's SOCKET_* → Vuex action mapping
13+
socket.on("connect", () => {
14+
store.dispatch("SOCKET_connect");
15+
});
16+
17+
socket.on("nameknown", () => {
18+
store.dispatch("SOCKET_nameknown");
19+
});
20+
21+
socket.on("namenotknown", () => {
22+
store.dispatch("SOCKET_namenotknown");
23+
});
24+
25+
socket.on("cancelLogin", () => {
26+
store.dispatch("SOCKET_cancelLogin");
27+
});
28+
29+
socket.on("cancelSign", () => {
30+
store.dispatch("SOCKET_cancelSign");
31+
});
32+
33+
socket.on("signedAttempt", (data) => {
34+
store.dispatch("SOCKET_signedAttempt", data);
35+
});
36+
37+
socket.on("signedSignDataAttempt", (data) => {
38+
store.dispatch("SOCKET_signedSignDataAttempt", data);
39+
});
40+
41+
socket.on("phoneverified", () => {
42+
store.dispatch("SOCKET_phoneverified");
43+
});
44+
45+
socket.on("emailverified", () => {
46+
store.dispatch("SOCKET_emailverified");
47+
});
48+
1149
export default socket;

0 commit comments

Comments
 (0)