Skip to content

Commit 5fdbaa8

Browse files
committed
Replace providerRef with outer ref reference and update test.yml
1 parent b70f478 commit 5fdbaa8

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ jobs:
3030
USER_SERVICE_URL: ${{ vars.USER_SERVICE_URL }}
3131
MATCHING_SERVICE_URL: ${{ vars.MATCHING_SERVICE_URL }}
3232
HISTORY_SERVICE_URL: ${{ vars.HISTORY_SERVICE_URL }}
33+
SIGNALLING_SERVICE_URL: ${{ vars.SIGNALLING_SERVICE_URL }}
3334
JWT_SECRET: ${{ secrets.JWT_SECRET }}
3435
QUESTION_FIREBASE_CREDENTIAL_PATH: ${{ vars.QUESTION_SERVICE_FIREBASE_CREDENTIAL_PATH }}
3536
HISTORY_FIREBASE_CREDENTIAL_PATH: ${{ vars.HISTORY_SERVICE_FIREBASE_CREDENTIAL_PATH }}
3637
DB_CLOUD_URI: ${{ secrets.USER_SERVICE_DB_CLOUD_URI }}
3738
USER_SERVICE_PORT: ${{ vars.USER_SERVICE_PORT }}
3839
MATCHING_SERVICE_PORT: ${{ vars.MATCHING_SERVICE_PORT }}
3940
HISTORY_SERVICE_PORT: ${{ vars.HISTORY_SERVICE_PORT }}
41+
SIGNALLING_SERVICE_PORT: ${{ vars.SIGNALLING_SERVICE_PORT }}
4042
MATCHING_SERVICE_TIMEOUT: ${{ vars.MATCHING_SERVICE_TIMEOUT }}
4143
REDIS_URL: ${{ vars.REDIS_URL }}
4244
QUESTION_SERVICE_GRPC_URL: ${{ vars.QUESTION_SERVICE_GPRC_URL }}
@@ -46,6 +48,7 @@ jobs:
4648
echo "NEXT_PUBLIC_USER_SERVICE_URL=$USER_SERVICE_URL" >> .env
4749
echo "NEXT_PUBLIC_MATCHING_SERVICE_URL=$MATCHING_SERVICE_URL" >> .env
4850
echo "NEXT_PUBLIC_HISTORY_SERVICE_URL=$HISTORY_SERVICE_URL" >> .env
51+
echo "NEXT_PUBLIC_SIGNALLING_SERVICE_URL=$SIGNALLING_SERVICE_URL" >> .env
4952
5053
cd ../question-service
5154
echo "FIREBASE_CREDENTIAL_PATH=$QUESTION_FIREBASE_CREDENTIAL_PATH" >> .env
@@ -67,6 +70,9 @@ jobs:
6770
echo "FIREBASE_CREDENTIAL_PATH=$HISTORY_FIREBASE_CREDENTIAL_PATH" >> .env
6871
echo "PORT=$HISTORY_SERVICE_PORT" >> .env
6972
73+
cd ../signalling-service
74+
echo "PORT=$SIGNALLING_SERVICE_PORT" >> .env
75+
7076
- name: Create Database Credential Files
7177
env:
7278
QUESTION_FIREBASE_JSON: ${{ secrets.QUESTION_SERVICE_FIREBASE_CREDENTIAL }}
@@ -101,6 +107,7 @@ jobs:
101107
QUESTION_SERVICE_URL: ${{ vars.QUESTION_SERVICE_URL }}
102108
MATCHING_SERVICE_URL: ${{ vars.MATCHING_SERVICE_URL }}
103109
HISTORY_SERVICE_URL: ${{ vars.HISTORY_SERVICE_URL }}
110+
SIGNALLING_SERVICE_URL: ${{ vars.SIGNALLING_SERVICE_URL }}
104111
run: |
105112
echo "Testing Question Service..."
106113
curl -sSL -o /dev/null $QUESTION_SERVICE_URL && echo "Question Service is up"
@@ -117,5 +124,10 @@ jobs:
117124
echo "WebSocket for Matching Service is live"
118125
fi
119126
# Add in test for matching service in the future
120-
127+
echo "Testing Signalling Service..."
128+
if ! (echo "Hello" | websocat $SIGNALLING_SERVICE_URL); then
129+
echo "WebSocket for Signalling Service is not live"
130+
else
131+
echo "WebSocket for Signalling Service is live"
132+
fi
121133
# We can add more tests here

apps/frontend/src/app/collaboration/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export default function CollaborationPage(props: CollaborationProps) {
399399
language={selectedLanguage}
400400
setMatchedUser={setMatchedUser}
401401
handleCloseCollaboration={handleCloseCollaboration}
402-
// providerRef={providerRef}
402+
providerRef={providerRef}
403403
matchedUser={matchedUser}
404404
onCodeChange={handleCodeChange}
405405
/>

apps/frontend/src/components/CollaborativeEditor/CollaborativeEditor.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface CollaborativeEditorProps {
3232
language: string;
3333
setMatchedUser: Dispatch<SetStateAction<string>>;
3434
handleCloseCollaboration: (type: string) => void;
35-
// providerRef: MutableRefObject<WebrtcProvider | null>;
35+
providerRef: MutableRefObject<WebrtcProvider | null>;
3636
matchedUser: string;
3737
onCodeChange: (code: string) => void;
3838
}
@@ -77,7 +77,7 @@ const CollaborativeEditor = forwardRef(
7777
ref: ForwardedRef<CollaborativeEditorHandle>
7878
) => {
7979
const editorRef = useRef(null);
80-
const providerRef = useRef<WebrtcProvider | null>(null);
80+
// const providerRef = useRef<WebrtcProvider | null>(null);
8181
const [selectedLanguage, setSelectedLanguage] = useState("JavaScript");
8282
let sessionEndNotified = false;
8383

@@ -168,9 +168,9 @@ const CollaborativeEditor = forwardRef(
168168

169169
useImperativeHandle(ref, () => ({
170170
endSession: () => {
171-
if (providerRef.current) {
171+
if (props.providerRef.current) {
172172
// Set awareness state to indicate session ended to notify peer about session ending
173-
providerRef.current.awareness.setLocalStateField(
173+
props.providerRef.current.awareness.setLocalStateField(
174174
"sessionEnded",
175175
true
176176
);
@@ -191,7 +191,7 @@ const CollaborativeEditor = forwardRef(
191191
maxConns: 2,
192192
});
193193

194-
providerRef.current = provider;
194+
props.providerRef.current = provider;
195195
const ytext = ydoc.getText("codemirror");
196196
const undoManager = new Y.UndoManager(ytext);
197197

@@ -222,8 +222,8 @@ const CollaborativeEditor = forwardRef(
222222

223223
props.handleCloseCollaboration("peer");
224224
sessionEndNotified = true;
225-
if (providerRef.current) {
226-
providerRef.current.disconnect();
225+
if (props.providerRef.current) {
226+
props.providerRef.current.disconnect();
227227
}
228228
return;
229229
}

0 commit comments

Comments
 (0)