From dbdd78b9310e8ea53f3c345233415553177853b8 Mon Sep 17 00:00:00 2001 From: jrcleber Date: Tue, 9 Jul 2024 09:52:58 -0300 Subject: [PATCH] ws-readme --- src/websocket/Readme.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/websocket/Readme.md b/src/websocket/Readme.md index 1a7bec0e..a9bdda73 100644 --- a/src/websocket/Readme.md +++ b/src/websocket/Readme.md @@ -67,14 +67,15 @@ ws.onclose = (event) => { ### 4. Exemplo completo ```javascript -const url = 'ws://localhost:8084/ws/events'; -const reconnectInterval = 5000; // 5 segundos +const url = "ws://localhost:8084/ws/events"; +const token = "" +const reconnectInterval = 5000; function socket(eventName, callback) { - const ws = new WebSocket(`${url}?event=${encodeURIComponent(eventName)}&token=${encodeURIComponent("{{auth.token}}")}`); + const ws = new WebSocket(`${url}?event=${encodeURIComponent(eventName)}&token=${encodeURIComponent(token)}`); ws.onopen = () => { - console.log('Connected to the server'); + console.log("Connected to the server"); }; ws.onmessage = (event) => {