Skip to content

Commit

Permalink
ws-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jrCleber committed Jul 9, 2024
1 parent 145b3f6 commit dbdd78b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/websocket/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit dbdd78b

Please sign in to comment.