+
{new Date(msg.time_sent).toLocaleTimeString()}
- {msg.chatter_id}:
+
+ {" "}
+ {msg.chatter_id}:{" "}
+
{msg.message}
))}
@@ -145,4 +134,4 @@ const ChatPanel: React.FC
= ({ streamId }) => {
);
};
-export default ChatPanel;
\ No newline at end of file
+export default ChatPanel;
diff --git a/frontend/src/context/SocketContext.tsx b/frontend/src/context/SocketContext.tsx
new file mode 100644
index 0000000..b75db69
--- /dev/null
+++ b/frontend/src/context/SocketContext.tsx
@@ -0,0 +1,57 @@
+import React, { createContext, useContext, useEffect, useState } from 'react';
+import { io, Socket } from 'socket.io-client';
+
+interface SocketContextType {
+ socket: Socket | null;
+ isConnected: boolean;
+}
+
+const SocketContext = createContext(undefined);
+
+export const SocketProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
+ const [socket, setSocket] = useState(null);
+ const [isConnected, setIsConnected] = useState(false);
+
+ useEffect(() => {
+ const newSocket = io("http://localhost:8080", {
+ path: "/socket.io/",
+ withCredentials: true,
+ transports: ['websocket'],
+ upgrade: false
+ });
+
+ newSocket.on('connect', () => {
+ console.log('Socket connected!');
+ setIsConnected(true);
+ });
+
+ newSocket.on('connect_error', (error) => {
+ console.error('Socket connection error:', error);
+ });
+
+ newSocket.on('disconnect', () => {
+ console.log('Socket disconnected!');
+ setIsConnected(false);
+ });
+
+ setSocket(newSocket);
+
+ return () => {
+ newSocket.close();
+ };
+ }, []);
+
+ return (
+
+ {children}
+
+ );
+};
+
+export const useSocket = () => {
+ const context = useContext(SocketContext);
+ if (context === undefined) {
+ throw new Error('useSocket must be used within a SocketProvider');
+ }
+ return context;
+};
\ No newline at end of file
diff --git a/nginx/nginx.conf b/nginx/nginx.conf
index 573f21a..199c658 100644
--- a/nginx/nginx.conf
+++ b/nginx/nginx.conf
@@ -37,6 +37,7 @@ rtmp {
}
http {
+ access_log off;
# Enable HLS
server {
listen 8080;
diff --git a/web_server/blueprints/streams.py b/web_server/blueprints/streams.py
index 6ca9c63..e81082b 100644
--- a/web_server/blueprints/streams.py
+++ b/web_server/blueprints/streams.py
@@ -134,7 +134,7 @@ def get_specific_stream(streamer_username, stream_id):
if stream:
return jsonify(stream)
- abort(404)
+ return jsonify({'error': 'Stream not found'}), 404
@login_required
@stream_bp.route('/get_followed_streamers')