UPDATE: Improved chat tranmission speed by 3seconds
This commit is contained in:
@@ -35,7 +35,7 @@ const StreamerRoute: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// streamId=0 is a special case for the streamer's latest stream
|
// streamId=0 is a special case for the streamer's latest stream
|
||||||
return isLive ? <VideoPage streamId={0} /> : (streamerName ? <UserPage username={streamerName} /> : <div>Error: Streamer not found</div>);
|
return isLive ? <VideoPage streamId={1} /> : (streamerName ? <UserPage username={streamerName} /> : <div>Error: Streamer not found</div>);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default StreamerRoute;
|
export default StreamerRoute;
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ http {
|
|||||||
|
|
||||||
location /socket.io/ {
|
location /socket.io/ {
|
||||||
proxy_pass http://web_server:5000/socket.io/;
|
proxy_pass http://web_server:5000/socket.io/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_buffering off;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from datetime import datetime
|
|||||||
from flask_socketio import SocketIO
|
from flask_socketio import SocketIO
|
||||||
|
|
||||||
chat_bp = Blueprint("chat", __name__)
|
chat_bp = Blueprint("chat", __name__)
|
||||||
socketio = SocketIO(cors_allowed_origins="*")
|
socketio = SocketIO()
|
||||||
|
|
||||||
# <---------------------- ROUTES NEEDS TO BE CHANGED TO VIDEO OR DELETED AS DEEMED APPROPRIATE ---------------------->
|
# <---------------------- ROUTES NEEDS TO BE CHANGED TO VIDEO OR DELETED AS DEEMED APPROPRIATE ---------------------->
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ socketio = SocketIO(cors_allowed_origins="*")
|
|||||||
def handle_connection() -> None:
|
def handle_connection() -> None:
|
||||||
"""
|
"""
|
||||||
Accept the connection from the frontend.
|
Accept the connection from the frontend.
|
||||||
"""
|
"""
|
||||||
print("Client Connected") # Confirmation connect has been made
|
print("Client Connected") # Confirmation connect has been made
|
||||||
|
|
||||||
|
|
||||||
@@ -64,10 +64,13 @@ def get_past_chat(stream_id: int):
|
|||||||
LIMIT 50
|
LIMIT 50
|
||||||
)
|
)
|
||||||
ORDER BY time_sent ASC;""", (stream_id,))
|
ORDER BY time_sent ASC;""", (stream_id,))
|
||||||
|
|
||||||
db.close_connection()
|
db.close_connection()
|
||||||
|
|
||||||
# Create JSON output of chat_history to pass through NGINX proxy
|
# Create JSON output of chat_history to pass through NGINX proxy
|
||||||
chat_history = [{"chatter_id": chat[0], "message": chat[1], "time_sent": chat[2]} for chat in all_chats]
|
print(f"Bollocks: {all_chats}", flush=True)
|
||||||
|
chat_history = [{"chatter_id": chat["chatter_id"], "message": chat["message"], "time_sent": chat["time_sent"]} for chat in all_chats]
|
||||||
|
print(f"chat history: {chat_history}", flush=True)
|
||||||
|
|
||||||
# Pass the chat history to the proxy
|
# Pass the chat history to the proxy
|
||||||
return jsonify({"chat_history": chat_history}), 200
|
return jsonify({"chat_history": chat_history}), 200
|
||||||
|
|||||||
Binary file not shown.
@@ -49,6 +49,11 @@ INSERT INTO subscribes (user_id, subscribed_id, since, expires) VALUES
|
|||||||
INSERT INTO users (username, password, email, num_followers, stream_key, is_partnered, bio) VALUES
|
INSERT INTO users (username, password, email, num_followers, stream_key, is_partnered, bio) VALUES
|
||||||
('GamerDude2', 'password123', 'gamerdude3@gmail.com', 3200, '7890', 0, 'Streaming my gaming adventures!');
|
('GamerDude2', 'password123', 'gamerdude3@gmail.com', 3200, '7890', 0, 'Streaming my gaming adventures!');
|
||||||
|
|
||||||
|
INSERT INTO chat (stream_id, chatter_id, message) VALUES
|
||||||
|
(1, 'Susan', 'Hey Every, loving the stream'),
|
||||||
|
(1, 'Susan', 'This stream is crazy man'),
|
||||||
|
(1, 'JohnnyHash', 'Woah, cannot believe that');
|
||||||
|
|
||||||
SELECT * FROM users;
|
SELECT * FROM users;
|
||||||
SELECT * FROM follows;
|
SELECT * FROM follows;
|
||||||
SELECT * FROM user_preferences;
|
SELECT * FROM user_preferences;
|
||||||
@@ -63,4 +68,16 @@ SELECT * FROM stream_tags;
|
|||||||
SELECT name FROM sqlite_master WHERE type='table';
|
SELECT name FROM sqlite_master WHERE type='table';
|
||||||
|
|
||||||
|
|
||||||
SELECT isLive FROM streams WHERE user_id = '5';
|
SELECT isLive FROM streams WHERE user_id = '5';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SELECT *
|
||||||
|
FROM (
|
||||||
|
SELECT chatter_id, message, time_sent
|
||||||
|
FROM chat
|
||||||
|
WHERE stream_id = 1
|
||||||
|
ORDER BY time_sent DESC
|
||||||
|
LIMIT 50
|
||||||
|
)
|
||||||
|
ORDER BY time_sent ASC
|
||||||
Reference in New Issue
Block a user