Answer the question
In order to leave comments, you need to log in
What is the difference between React-native WebSocket and NodeJS ws?
NodeJS:
const WebSocket = require('ws');
const ws = new WebSocket('wss://siteurl');
ws.on('open', function open() {
ws.send('');
});
ws.on('message', function incoming(message) {
console.log(message);
});
let connection = new WebSocket('wss://siteurl');
connection.onopen = () => {
connection.send('');
};
connection.onmessage = ((event) => {
console.log(event);
});
{"data": [], "isTrusted": false}
const socket = new WebSocket('wss://siteurl');
socket.onopen = () => {
console.log('Socket connected!');
socket.send('');
}
socket.onmessage = (message) => {
console.log(`Message:\n`, message.data);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question