Skip to content

Commit

Permalink
Arnab/livekit depl (#775)
Browse files Browse the repository at this point in the history
* refactor: added code for joining livekit room for listeners (#731)

* feat: drop in livekit inplace of livepeer

* feat: added microphone

* feat: added mic

* feat: added access control

* feat: fixes for livekit API call

* feat: meta messages added for joining

* fix: add meta message for accept

---------

Co-authored-by: Nilesh Gupta <[email protected]>
  • Loading branch information
arn4b and 0xNilesh authored Oct 12, 2023
1 parent 21b61dc commit d6e1607
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
11 changes: 11 additions & 0 deletions packages/restapi/src/lib/space/acceptPromotionRequest.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import type Space from './Space';
import { addSpeakers } from './addSpeakers';
import sendLiveSpaceData from './helpers/sendLiveSpaceData';

import { pCAIP10ToWallet } from '../helpers';
import {
SPACE_ACCEPT_REQUEST_TYPE,
SPACE_INVITE_ROLES,
} from '../payloads/constants';
import { META_ACTION } from '../types';

export interface IAcceptPromotionRequestType {
signalData: any;
Expand Down Expand Up @@ -35,6 +37,15 @@ export async function acceptPromotionRequest(
env: this.env,
});

await sendLiveSpaceData({
spaceId: this.spaceSpecificData.spaceId,
pgpPrivateKey: this.pgpPrivateKey,
env: this.env,
signer: this.signer,
// liveSpaceData: modifiedLiveSpaceData,
action: META_ACTION.PROMOTE_TO_SPEAKER,
});

// accept the promotion request
// this.acceptRequest({
// signalData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const LiveWidgetContent: React.FC<LiveWidgetContentProps> = ({
initSpaceObject,
raisedHandInfo,
} = useSpaceData();
console.log("🚀 ~ file: LiveWidgetContent.tsx:66 ~ spaceObjectData:", spaceObjectData)
console.log("🚀 ~ file: LiveWidgetContent.tsx:66 ~ raisedHandInfo:", raisedHandInfo)

const isMicOn = spaceObjectData?.connectionData?.local?.audio;
Expand All @@ -89,7 +90,8 @@ export const LiveWidgetContent: React.FC<LiveWidgetContentProps> = ({
}, [isListener, isHost, spaceData]);

useEffect(() => {
if (!spaceObjectData?.connectionData?.local?.stream || !isRequestedForMic)
// if (!spaceObjectData?.connectionData?.local?.stream || !isRequestedForMic)
if (!isRequestedForMic)
return;

const requestedForMicFromEffect = async () => {
Expand Down Expand Up @@ -183,8 +185,8 @@ export const LiveWidgetContent: React.FC<LiveWidgetContentProps> = ({
console.log('isListner', isListener);
if (
isListener &&
!isHost &&
spaceObjectData.connectionData.local.address
!isHost
// && spaceObjectData.connectionData.local.address
) {
console.log('joining as a listener');
await spacesObjectRef?.current?.join?.();
Expand Down Expand Up @@ -212,7 +214,7 @@ export const LiveWidgetContent: React.FC<LiveWidgetContentProps> = ({
// joining as a speaker
useEffect(() => {
if (
!spaceObjectData?.connectionData?.local?.stream ||
// !spaceObjectData?.connectionData?.local?.stream ||
!isSpeaker ||
(spaceObjectData?.connectionData?.incoming?.length ?? 0) > 1
)
Expand Down
2 changes: 1 addition & 1 deletion packages/uiweb/src/lib/hooks/space/usePushSpaceSocket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const usePushSpaceSocket = ({

pushSpaceSocket?.on('SPACES_MESSAGES', async (message: any) => {
console.log('SPACES_MESSAGES RECEIVED', message);
if (message?.messageCategory === 'Request') {
if (message?.messageCategory === 'Request' || message?.messageCategory === 'Approve') {
/*
- Will be executed on host's end of a live space
- When a listener joins this fires a meta message telling everyone the same
Expand Down
1 change: 1 addition & 0 deletions packages/uiweb/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2471,6 +2471,7 @@ clsx@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.0.0.tgz#12658f3fd98fafe62075595a5c30e43d18f3d00b"
integrity sha512-rQ1+kcj+ttHG0MKVGBUXwayCCF1oh39BF5COIpRzuCEv8Mwjv0XucrI2ExNTOn9IlLifGClWQcU9BrZORvtw6Q==

color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
Expand Down

0 comments on commit d6e1607

Please sign in to comment.