Skip to content

Commit

Permalink
propagated metadata update by data message (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 authored Jun 6, 2023
1 parent bbd2000 commit 63d611d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 13 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugnmeet-client",
"version": "1.4.0",
"version": "1.4.1",
"author": "Jibon L. Costa",
"license": "MIT",
"scripts": {
Expand All @@ -27,7 +27,7 @@
"i18next": "22.5.0",
"i18next-browser-languagedetector": "7.0.2",
"i18next-http-backend": "2.2.1",
"livekit-client": "1.9.7",
"livekit-client": "1.10.0",
"lodash": "4.17.21",
"microsoft-cognitiveservices-speech-sdk": "^1.29.0",
"mobile-detect": "1.4.5",
Expand All @@ -52,18 +52,18 @@
"@bufbuild/protoc-gen-es": "1.2.1",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
"@types/lodash": "4.14.195",
"@types/react": "18.2.7",
"@types/react": "18.2.8",
"@types/react-dom": "18.2.4",
"@types/sanitize-html": "2.9.0",
"@types/video.js": "^7.3.52",
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.59.8",
"@typescript-eslint/eslint-plugin": "5.59.9",
"@typescript-eslint/parser": "5.59.9",
"autoprefixer": "10.4.14",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "11.0.0",
"css-loader": "6.8.1",
"css-minimizer-webpack-plugin": "5.0.0",
"eslint": "8.41.0",
"eslint": "8.42.0",
"eslint-config-prettier": "8.8.0",
"eslint-import-resolver-typescript": "3.5.5",
"eslint-plugin-import": "2.27.5",
Expand All @@ -87,9 +87,9 @@
"tailwindcss": "3.3.2",
"terser-webpack-plugin": "5.3.9",
"ts-loader": "9.4.3",
"typescript": "5.0.4",
"webpack": "5.85.0",
"webpack-cli": "5.1.1",
"typescript": "5.1.3",
"webpack": "5.85.1",
"webpack-cli": "5.1.3",
"webpack-dev-server": "4.15.0"
},
"lint-staged": {
Expand Down
5 changes: 3 additions & 2 deletions src/helpers/livekit/ConnectLivekit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,11 @@ export default class ConnectLivekit
this.roomConnectionStatusState('connected'),
);
room.on(RoomEvent.Disconnected, this.onDisconnected);
room.on(
// at present for updating metadata, we'll do it manually
/*room.on(
RoomEvent.RoomMetadataChanged,
this.handleRoomMetadata.setRoomMetadata,
);
);*/
room.on(
RoomEvent.ActiveSpeakersChanged,
this.handleActiveSpeakers.activeSpeakersChanged,
Expand Down
8 changes: 8 additions & 0 deletions src/helpers/livekit/HandleDataMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ import {
DataMsgType,
} from '../proto/plugnmeet_datamessage_pb';
import { GenerateAzureTokenRes } from '../proto/plugnmeet_speech_services_pb';
import HandleRoomMetadata from './HandleRoomMetadata';

export default class HandleDataMessages {
private that: IConnectLivekit;
private requestedParticipant: Participant | undefined;
private metadataHandler: HandleRoomMetadata;
private lastId: string | undefined = undefined;

constructor(that: IConnectLivekit) {
this.that = that;
this.metadataHandler = new HandleRoomMetadata();
}

public dataReceived = (
Expand All @@ -37,6 +41,7 @@ export default class HandleDataMessages {
console.error(error);
return;
}
this.lastId = data.messageId;

if (kind === DataPacket_Kind.RELIABLE) {
if (data.type === DataMsgType.SYSTEM) {
Expand Down Expand Up @@ -87,6 +92,9 @@ export default class HandleDataMessages {
);
}
break;
case DataMsgBodyType.UPDATE_ROOM_METADATA:
this.metadataHandler.setRoomMetadata(body.msg, this.lastId);
break;
}
};

Expand Down
10 changes: 9 additions & 1 deletion src/helpers/livekit/HandleRoomMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ import { addChatMessage } from '../../store/slices/chatMessagesSlice';
export default class HandleRoomMetadata {
private metadata: IRoomMetadata | null = null;
private welcomeMessage: string | undefined = undefined;
private lastMessageId: string | undefined = undefined;

public setRoomMetadata = (metadata: string, messageId?: string) => {
if (messageId && this.lastMessageId && messageId === this.lastMessageId) {
// if message id is same then we won't do anything.
return;
} else {
this.lastMessageId = messageId;
}

public setRoomMetadata = (metadata: string) => {
if (!isEmpty(metadata)) {
try {
this.metadata = JSON.parse(metadata);
Expand Down
6 changes: 6 additions & 0 deletions src/helpers/proto/plugnmeet_datamessage_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ export enum DataMsgBodyType {
*/
AZURE_COGNITIVE_SERVICE_SPEECH_TOKEN = 24,

/**
* @generated from enum value: UPDATE_ROOM_METADATA = 25;
*/
UPDATE_ROOM_METADATA = 25,

/**
* USER type
*
Expand Down Expand Up @@ -194,6 +199,7 @@ proto3.util.setEnumType(DataMsgBodyType, 'plugnmeet.DataMsgBodyType', [
{ no: 15, name: 'JOIN_BREAKOUT_ROOM' },
{ no: 23, name: 'SPEECH_SUBTITLE_TEXT' },
{ no: 24, name: 'AZURE_COGNITIVE_SERVICE_SPEECH_TOKEN' },
{ no: 25, name: 'UPDATE_ROOM_METADATA' },
{ no: 16, name: 'CHAT' },
{ no: 17, name: 'SCENE_UPDATE' },
{ no: 18, name: 'POINTER_UPDATE' },
Expand Down

0 comments on commit 63d611d

Please sign in to comment.