You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
967 B
49 lines
967 B
4 years ago
|
var path = require('path');
|
||
|
var app = require('express')();
|
||
|
var http = require('http').Server(app);
|
||
|
var io = require('socket.io')(http);
|
||
|
|
||
|
const socketAuth = require('socketio-auth');
|
||
|
|
||
|
socketoptions = {
|
||
|
secure:true,
|
||
|
reconnect: true,
|
||
|
rejectUnauthorized : false
|
||
|
};
|
||
|
|
||
|
|
||
|
// Client
|
||
|
var io2 = require('socket.io-client');
|
||
|
var socket = io2.connect('https://83.212.78.17:3088', socketoptions);
|
||
|
|
||
|
socket.on('connection', s => {
|
||
|
console.error('socket2 connection');
|
||
|
var id = s.id
|
||
|
|
||
|
|
||
|
var roomiot = 'iot'
|
||
|
socket.emit('iot', roomiot);
|
||
|
|
||
|
socket.emit('subscribe', roomiot);
|
||
|
|
||
|
socket.emit('pingServerEmit', roomiot);
|
||
|
|
||
|
|
||
|
s.on('message', function (data) {
|
||
|
console.log('from room1 '+data);
|
||
|
});
|
||
|
s.on('iot', function (data) {
|
||
|
console.log('from room1 '+data);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
var roomiot = 'iot'
|
||
|
socket.emit('action', roomiot);
|
||
|
|
||
|
socket.on('message', function (data) {
|
||
|
console.log('from room '+data);
|
||
|
});
|
||
|
|
||
|
|
||
|
|