Skip to content

Commit

Permalink
Merge pull request #16 from tsd2024/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jakub-mrow authored Apr 8, 2024
2 parents d280c38 + 077ea5f commit d149ea4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
NEXTAUTH_URL: ${{ vars.NEXTAUTH_URL }}
BACKEND_URL: ${{ vars.BACKEND_URL }}
WEBSOCKET_PROTOCOL: wss

run: |
npx sst deploy --stage prod
1 change: 1 addition & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const nextConfig = {
env: {
BACKEND_URL: process.env.BACKEND_URL,
WEBSOCKET_PROTOCOL: process.env.WEBSOCKET_PROTOCOL,
},
experimental: {
missingSuspenseWithCSRBailout: false,
Expand Down
4 changes: 3 additions & 1 deletion src/app/create-room/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ export default function CreateRoomPage() {
});

const router = useRouter();
const BACKEND_URL = process.env.BACKEND_URL;
const WEBSOCKET_PROTOCOL = process.env.WEBSOCKET_PROTOCOL;

const generateId = () => {
return uuidv4(); // <-- Generate UUID
};

const { sendMessage, lastMessage, readyState } = useWebSocket('ws://localhost:8009/api/v1/room', {
const { sendMessage, lastMessage, readyState } = useWebSocket(`${WEBSOCKET_PROTOCOL}://${BACKEND_URL}/api/v1/room`, {
shouldReconnect: () => true,
onOpen: () => console.log("opened"),
onMessage: (event) => {
Expand Down
3 changes: 2 additions & 1 deletion src/app/rooms/[roomId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Player = {

export default function RoomPage({ params }: { params: { roomId: string } }) {
const BACKEND_URL = process.env.BACKEND_URL;
const WEBSOCKET_PROTOCOL = process.env.WEBSOCKET_PROTOCOL;

const searchParams = useSearchParams()
const playerId = searchParams.get('playerId')
Expand All @@ -48,7 +49,7 @@ export default function RoomPage({ params }: { params: { roomId: string } }) {
playCard(card);
};

const { sendMessage, lastMessage, readyState } = useWebSocket(`ws://${BACKEND_URL}/api/v1/room`, {
const { sendMessage, lastMessage, readyState } = useWebSocket(`${WEBSOCKET_PROTOCOL}://${BACKEND_URL}/api/v1/room`, {
shouldReconnect: () => true,
onOpen: () => {
console.log("opened");
Expand Down

0 comments on commit d149ea4

Please sign in to comment.