Skip to content

Latest commit

 

History

History
25 lines (21 loc) · 591 Bytes

File metadata and controls

25 lines (21 loc) · 591 Bytes
title Подключение к STOMP
sidebarTitle Подключение к STOMP

Подключиться к топику с аутентификацией по токену

import { Client } from '@stomp/stompjs';

const client = new Client({
  brokerURL: 'ws://localhost:8080/ws',
  connectHeaders: {
    'passcode': 'your-auth-token-here',
  },
  onConnect: () => {
    client.subscribe('/topic/your-topic', message => {
      const data = JSON.parse(message.body);
      console.log('Received message:', data);
    });
  }
});

client.activate();