Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebSocket integration #337

Merged
merged 4 commits into from
Nov 10, 2024
Merged

Add WebSocket integration #337

merged 4 commits into from
Nov 10, 2024

Conversation

Process-ing
Copy link
Contributor

Closes #233

This PR sets up Socket.IO in the frontend and creates a wrapper class to more effortlessly use the WebSocket communication.

To test this, run the backend on the feature/websockets branch add the following to index.tsx

import { sessionsSocket } from './api/socket'

// ...

sessionsSocket.connect()
sessionsSocket.on('response', data => {
    console.log(data);
});

// Send message to server
function sendMessage(message) {
    sessionsSocket.emit('test', message);
};

sessionsSocket.on('connect', () => {
    sendMessage('message');
});

setTimeout(() => {
    sessionsSocket.disconnect();
}, 1000);

Copy link

netlify bot commented Nov 9, 2024

Deploy Preview for tts-fe-preview ready!

Name Link
🔨 Latest commit 020dbc8
🔍 Latest deploy log https://app.netlify.com/sites/tts-fe-preview/deploys/672fbaafce53230008d7fdd1
😎 Deploy Preview https://deploy-preview-337--tts-fe-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

src/api/socket.ts Outdated Show resolved Hide resolved
Copy link
Member

@tomaspalma tomaspalma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@Process-ing Process-ing merged commit 5edb800 into develop Nov 10, 2024
5 checks passed
@Process-ing Process-ing deleted the feature/websockets branch November 10, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add web socket support to frontend
2 participants