refactor: Comment out play_sound event handler and related logic for future use
This commit is contained in:
@@ -155,45 +155,45 @@ def handle_authenticate(data):
|
||||
disconnect()
|
||||
|
||||
|
||||
@socketio.on("play_sound")
|
||||
@require_credits(1)
|
||||
def handle_play_sound(data):
|
||||
"""Handle play_sound event from client."""
|
||||
try:
|
||||
user = SocketIOService.get_user_from_socketio()
|
||||
# @socketio.on("play_sound")
|
||||
# @require_credits(1)
|
||||
# def handle_play_sound(data):
|
||||
# """Handle play_sound event from client."""
|
||||
# try:
|
||||
# user = SocketIOService.get_user_from_socketio()
|
||||
|
||||
if not user:
|
||||
logger.warning("SocketIO play_sound failed - no authenticated user")
|
||||
# emit("error", {"message": "Authentication required"})
|
||||
return
|
||||
# if not user:
|
||||
# logger.warning("SocketIO play_sound failed - no authenticated user")
|
||||
# # emit("error", {"message": "Authentication required"})
|
||||
# return
|
||||
|
||||
user_id = int(user["id"])
|
||||
sound_id = data.get("soundId")
|
||||
if not sound_id:
|
||||
logger.warning("SocketIO play_sound failed - no soundId provided")
|
||||
SocketIOService.emit_to_user(
|
||||
user_id, "error", {"message": "Sound ID required"}
|
||||
)
|
||||
return
|
||||
# user_id = int(user["id"])
|
||||
# sound_id = data.get("soundId")
|
||||
# if not sound_id:
|
||||
# logger.warning("SocketIO play_sound failed - no soundId provided")
|
||||
# SocketIOService.emit_to_user(
|
||||
# user_id, "error", {"message": "Sound ID required"}
|
||||
# )
|
||||
# return
|
||||
|
||||
# Import and use the VLC service to play the sound
|
||||
from app.services.vlc_service import vlc_service
|
||||
# # Import and use the VLC service to play the sound
|
||||
# from app.services.vlc_service import vlc_service
|
||||
|
||||
logger.info(f"User {user_id} playing sound {sound_id} via SocketIO")
|
||||
# logger.info(f"User {user_id} playing sound {sound_id} via SocketIO")
|
||||
|
||||
# Play the sound using the VLC service
|
||||
success = vlc_service.play_sound(sound_id, user_id)
|
||||
# # Play the sound using the VLC service
|
||||
# success = vlc_service.play_sound(sound_id, user_id)
|
||||
|
||||
if not success:
|
||||
SocketIOService.emit_to_user(
|
||||
user_id,
|
||||
"error",
|
||||
{"message": f"Failed to play sound {sound_id}"},
|
||||
)
|
||||
# if not success:
|
||||
# SocketIOService.emit_to_user(
|
||||
# user_id,
|
||||
# "error",
|
||||
# {"message": f"Failed to play sound {sound_id}"},
|
||||
# )
|
||||
|
||||
except Exception as e:
|
||||
logger.exception(f"Error handling play_sound event: {e}")
|
||||
# emit("error", {"message": "Failed to play sound"})
|
||||
# except Exception as e:
|
||||
# logger.exception(f"Error handling play_sound event: {e}")
|
||||
# # emit("error", {"message": "Failed to play sound"})
|
||||
|
||||
|
||||
@socketio.on("disconnect")
|
||||
|
||||
Reference in New Issue
Block a user