conditional websocket url

This commit is contained in:
Adam 2024-08-27 17:02:51 -04:00
parent 78d6486822
commit bd5a3846ef

View file

@ -38,6 +38,14 @@ impl WebSocketContext {
#[component] #[component]
pub fn Websocket() -> impl IntoView { pub fn Websocket() -> impl IntoView {
let url;
if cfg!(debug_assertions) {
url = "ws://127.0.0.1:3030/websocket";
} else {
url = "wss://cards.doordesk.net/websocket";
}
let UseWebSocketReturn { let UseWebSocketReturn {
ready_state, ready_state,
message, message,
@ -45,7 +53,8 @@ pub fn Websocket() -> impl IntoView {
open, open,
close, close,
.. ..
} = use_websocket::<String, FromToStringCodec>("wss://cards.doordesk.net/websocket"); // } = use_websocket::<String, FromToStringCodec>("wss://cards.doordesk.net/websocket");
} = use_websocket::<String, FromToStringCodec>(url);
provide_context(WebSocketContext::new( provide_context(WebSocketContext::new(
ready_state, ready_state,