Answer the question
In order to leave comments, you need to log in
Socket IO data transfer?
How to make the console send data to the server? I tried:
Client:
var script = document.createElement("script");
script.src = "https://cdn.socket.io/socket.io-1.2.0.js"
document.body.appendChild(script);
script.onload = function() {
socket = io("wss://server-bots-owop.glitch.me");
socket.on("botsJoined", function(x, y){
return "hi";
});
};
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var port = 3000;
io.on('connection', function(socket){ // Когда на сервер выполняется подключение идет функция:
socket.on('123', function(){ // Когда с клиента на сервер отправляется информация 123, он делает:
io.emit('botsJoined'); // Имитирует ивент на стороне клиента, что боты зашли.
});
});
http.listen(port, function(){
console.log('listening on *:' + port);
});
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