Skip to content

Commit 26a980a

Browse files
implemented user leaving the call and removing the user from the list of users to refresh all other users in the room to see one user has left
1 parent db0753f commit 26a980a

File tree

4 files changed

+115
-46
lines changed

4 files changed

+115
-46
lines changed

.DS_Store

6 KB
Binary file not shown.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
version: '3'
2+
3+
services:
4+
mysql:
5+
image: mysql:8.0.22
6+
command: --default-authentication-plugin=mysql_native_password
7+
volumes:
8+
- mysqlvol:/var/lib/mysql
9+
- ./backup:/var/backup
10+
environment:
11+
MYSQL_ROOT_PASSWORD: defaultpassword
12+
ports:
13+
- "3306:3306"
14+
15+
redis:
16+
image: redis
17+
volumes:
18+
- redisvol:/data
19+
20+
taxi-rider-api:
21+
image: ridyio/ridy-rider-api
22+
restart: always
23+
depends_on:
24+
- "mysql"
25+
- "redis"
26+
- "taxi-admin-api"
27+
volumes:
28+
- ./img:/app/uploads
29+
- ./config-new:/app/config
30+
environment:
31+
- MYSQL_HOST=mysql
32+
- GATEWAY_SERVER_URL=http://x.x.x.x:3333
33+
- RIDER_SERVER_URL=http://x.x.x.x:4000
34+
- ENCRYPTION_KEY=lPw3ethAy4WqnWa3b4TAbCUJr89RifEs
35+
- REDIS_HOST=redis
36+
ports:
37+
- "4000:3000"
38+
39+
taxi-driver-api:
40+
image: ridyio/ridy-driver-api
41+
restart: always
42+
depends_on:
43+
- "mysql"
44+
- "redis"
45+
- "taxi-admin-api"
46+
volumes:
47+
- ./img:/app/uploads
48+
- ./config-new:/app/config
49+
environment:
50+
- MYSQL_HOST=mysql
51+
- GATEWAY_SERVER_URL=http://x.x.x.x:3333
52+
- DRIVER_SERVER_URL=http://x.x.x.x:4002
53+
- REDIS_HOST=redis
54+
- ENCRYPTION_KEY=lPw3ethAy4WqnWa3b4TAbCUJr89RifEs
55+
ports:
56+
- "4002:3000"
57+
58+
taxi-admin-api:
59+
image: ridyio/ridy-admin-api
60+
restart: always
61+
depends_on:
62+
- "mysql"
63+
- "redis"
64+
links:
65+
- mysql
66+
volumes:
67+
- ./img:/app/uploads
68+
- ./config-new:/app/config
69+
environment:
70+
- MYSQL_HOST=mysql
71+
- REDIS_HOST=redis
72+
ports:
73+
- "4001:3000"
74+
75+
taxi-admin-panel:
76+
image: ridyio/ridy-admin-panel
77+
restart: always
78+
volumes:
79+
- taxiassets:/usr/share/nginx/html/assets
80+
ports:
81+
- "4003:80"
82+
83+
payment-gateways:
84+
image: ridyio/delivery-gateway-box
85+
depends_on:
86+
- "taxi-rider-api"
87+
ports:
88+
- "3333:3333"
89+
environment:
90+
- MYSQL_HOST=mysql
91+
- TEST_MODE=true
92+
- MYSQL_DB=ridy
93+
- GATEWAY_SERVER_URL=http://x.x.x.x:3333
94+
- ENCRYPTION_KEY=lPw3ethAy4WqnWa3b4TAbCUJr89RifEs
95+
96+
volumes:
97+
redisvol:
98+
mysqlvol:
99+
taxiassets:

client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingControllerComp.tsx

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,20 @@ const turnOnMicrophone = async (flag?: boolean) => {
117117
};
118118

119119
const leaveChannel = async () => {
120-
if (!client) {
121-
console.error("Agora client is not initialized");
122-
return;
123-
}
124-
125-
if (!client.localTracks.length) {
126-
console.error("No local tracks to unpublish");
127-
return;
128-
}
120+
console.log("user leaving 3");
129121
if (videoTrack) {
130122
await turnOnCamera(false);
131123
await client.unpublish(videoTrack);
132124
videoTrack.stop();
133125
}
134126

127+
console.log("user leaving 2");
135128
if (audioTrack) {
136129
await turnOnMicrophone(false);
137130
await client.unpublish(audioTrack);
138131
audioTrack.stop();
139132
}
133+
console.log("user leaving");
140134

141135
await client.leave();
142136
isJoined = false;
@@ -225,20 +219,14 @@ let MTComp = (function () {
225219
}, [userIds]);
226220

227221
useEffect(() => {
228-
if (client) {
229-
client.on("user-joined", (user: IAgoraRTCRemoteUser) => {
230-
setUserIds((userIds: any) => [...userIds, { user: user.uid }]);
231-
});
232-
client.on("user-offline", (uid: any, reason: any) => {
233-
console.log(`User ${uid} left the channel.`);
234-
});
235-
client.on("stream-removed", (user: IAgoraRTCRemoteUser) => {
236-
console.log(`Stream from user ${user.uid} removed.`);
237-
});
238-
client.on("stream-added", (user: IAgoraRTCRemoteUser) => {
239-
console.log("stream-added");
240-
});
241-
}
222+
client.on("user-joined", (user: IAgoraRTCRemoteUser) => {
223+
setUserIds((userIds: any) => [...userIds, { user: user.uid }]);
224+
});
225+
client.on("user-left", (user: IAgoraRTCRemoteUser, reason: any) => {
226+
setUserIds((userIds: any) =>
227+
userIds.filter((item: any) => item.user !== user.uid)
228+
);
229+
});
242230
}, [client]);
243231

244232
return (
@@ -407,6 +395,8 @@ MTComp = withMethodExposing(MTComp, [
407395
},
408396
execute: async (comp, values) => {
409397
let value = !comp.children.endCall.getView().value;
398+
console.log("");
399+
410400
await leaveChannel();
411401
comp.children.endCall.change(value);
412402
},

client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingStreamComp.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import { client } from "./videoMeetingControllerComp";
3434
import { IAgoraRTCRemoteUser, UID } from "agora-rtc-sdk-ng";
3535

3636
import { stringExposingStateControl } from "@lowcoder-ee/index.sdk";
37-
// import useAgora from "@lowcoder-ee/comps/hooks/agoraFunctions";
3837

3938
const FormLabel = styled(CommonBlueLabel)`
4039
font-size: 13px;
@@ -168,48 +167,29 @@ let VideoCompBuilder = (function (props) {
168167
videoCo!.style.height = container?.clientHeight + "px";
169168
videoCo!.style.width = container?.clientWidth + "px";
170169
};
171-
172170
useEffect(() => {
173171
client.on(
174172
"user-published",
175173
async (user: IAgoraRTCRemoteUser, mediaType: "video" | "audio") => {
176174
if (mediaType === "video") {
177-
178-
// const videoElement = document.createElement("video");
179-
// videoElement.id = user.uid + "";
180-
// videoElement.width = 640;
181-
// videoElement.height = 360;
182-
183-
// if (conRef.current) {
184-
// conRef.current.appendChild(videoElement);
185-
// }
186-
187-
// console.log("elementHtml", document.getElementById(user.uid + ""));
188-
189175
const remoteTrack = await client.subscribe(user, mediaType);
190-
remoteTrack.play(user.uid + "_v");
191-
console.log("user-published ", user.uid);
176+
remoteTrack.play(user.uid + "");
192177
}
193178
if (mediaType === "audio") {
194179
const remoteTrack = await client.subscribe(user, mediaType);
195180
remoteTrack.play();
196181
}
197182
}
198183
);
199-
200-
client.on("user-joined", (user: IAgoraRTCRemoteUser) => {
201-
console.log("drawer joined", user.uid);
202-
});
203-
}, [props.userId]);
204-
184+
}, [props.userId.value]);
205185
return (
206186
<EditorContext.Consumer>
207187
{(editorState) => (
208188
<ReactResizeDetector onResize={onResize}>
209189
<Container ref={conRef} $style={props.style}>
210190
<video
211191
ref={videoRef}
212-
id={props.userId.value + "_v"}
192+
id={props.userId.value}
213193
style={{ width: 300, height: 300 }}
214194
></video>
215195
</Container>

0 commit comments

Comments
 (0)