0

Мне необходимо получать инфу с канала 'newitems_cs', в принципе все(закрашенное не нужно).
Сервер: wss://wsn.dota2.net/wsn/
Мой код (он не работает):

 const ws = new WebSocket('wss://wsn.dota2.net/wsn/');
 ws.onopen = (data)=>{
    ws.send('newitems_cs');
    ws.on('newitems_cs', (data)=>{
        console.log(data);
    })
 }

вырезка с апи

1 ответ 1

1

Использовал пакет ws - https://www.npmjs.com/package/ws

const webSocket = require("ws");
const ws = new webSocket('wss://wsn.dota2.net/wsn/');

ws.on('open', function open() {
  console.log('Connection open')
  ws.send('history_cs');
});

  ws.on('message', function (message) {
    console.log(message);
  });
1
  • да, вы правы, точно такой же код час назад взял у другого человека)
    – Anton1
    10 мая 2019 в 14:24

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.