This commit is contained in:
parent
edbd2eef24
commit
d7eaf1584d
|
|
@ -10,7 +10,7 @@ import Meeting from '@/page/Meeting/index'
|
||||||
import NotFound from '@/page/NotFound/index'
|
import NotFound from '@/page/NotFound/index'
|
||||||
import { storage } from '@/utils'
|
import { storage } from '@/utils'
|
||||||
import { Spin } from "antd";
|
import { Spin } from "antd";
|
||||||
import { onSignalr, offSignalr } from "@/utils/package/signalr";
|
import { onInvitation } from "@/utils/package/signalr";
|
||||||
import JoinMeetingModal from "./components/JoinMeetingModal";
|
import JoinMeetingModal from "./components/JoinMeetingModal";
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
|
|
@ -61,7 +61,7 @@ const App: React.FC = () => {
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onSignalr((item: any) => {
|
onInvitation((item: any) => {
|
||||||
switch (item.key) {
|
switch (item.key) {
|
||||||
case 'Invitation':
|
case 'Invitation':
|
||||||
window.electron.joinNotification({
|
window.electron.joinNotification({
|
||||||
|
|
@ -72,9 +72,6 @@ const App: React.FC = () => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return () => {
|
|
||||||
offSignalr()
|
|
||||||
}
|
|
||||||
}, [])
|
}, [])
|
||||||
const handleResize = (): void => {
|
const handleResize = (): void => {
|
||||||
setWindowSize({
|
setWindowSize({
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,14 @@ export const startSignalr = () => {
|
||||||
.catch((err: any) => console.error('Error while establishing connection: ', err));
|
.catch((err: any) => console.error('Error while establishing connection: ', err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const onInvitation = (callBack: Function) => {
|
||||||
|
connection.on("Invitation", (roomNum: string, roomName: string, InviterName: string) => {
|
||||||
|
callBack({
|
||||||
|
key: 'Invitation',
|
||||||
|
roomNum, roomName, InviterName
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
export const onSignalr = (callBack: Function) => {
|
export const onSignalr = (callBack: Function) => {
|
||||||
if (connection) {
|
if (connection) {
|
||||||
connection.on("ReceiveMessage", (uid: string, userName: string, message: string) => {
|
connection.on("ReceiveMessage", (uid: string, userName: string, message: string) => {
|
||||||
|
|
@ -46,12 +54,6 @@ export const onSignalr = (callBack: Function) => {
|
||||||
type
|
type
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
connection.on("Invitation", (roomNum: string, roomName: string, InviterName: string) => {
|
|
||||||
callBack({
|
|
||||||
key: 'Invitation',
|
|
||||||
roomNum, roomName, InviterName
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const offSignalr = () => {
|
export const offSignalr = () => {
|
||||||
|
|
@ -60,7 +62,6 @@ export const offSignalr = () => {
|
||||||
connection.off('RefreshUserList');
|
connection.off('RefreshUserList');
|
||||||
connection.off('Operation');
|
connection.off('Operation');
|
||||||
connection.off('ForceExitRoom');
|
connection.off('ForceExitRoom');
|
||||||
connection.off('Invitation');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const onInvoke = async (str: string, data: any) => {
|
export const onInvoke = async (str: string, data: any) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue