elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


  Mostrar Temas
Páginas: [1]
1  Programación / Programación General / socket.io (10) Actualizar codigo AYUDA en: 21 Enero 2021, 20:14 pm
Estoy intentado pasar este codigo a la ultima version de socket.io y no lo consigo.
Este es el codigo y marco los errores que me da:




Código
  1. // https://www.webrtc-experiment.com/
  2.  
  3. var fs = require('fs');
  4.  
  5. // don't forget to use your own keys!
  6. var options = {
  7.    // key: fs.readFileSync('fake-keys/privatekey.pem'),
  8.    // cert: fs.readFileSync('fake-keys/certificate.pem')
  9.    key: fs.readFileSync('C:/Users/TONI1/Desktop/WebRTC-Experiment-master/socketio-over-nodejs/fake-keys/privatekey.pem'),
  10.    cert: fs.readFileSync('C:/Users/TONI1/Desktop/WebRTC-Experiment-master/socketio-over-nodejs/fake-keys/certificate.pem')
  11. };
  12.  
  13. // HTTPs server
  14. var app = require('https').createServer(options, function(request, response) {
  15.    response.writeHead(200, {
  16.        'Content-Type': 'text/html'
  17.    });
  18.    var link = 'https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs';
  19.    response.write('<title>socketio-over-nodejs</title><h1><a href="'+ link + '">socketio-over-nodejs</a></h1><pre>var socket = io.connect("https://webrtcweb.com:9559/");</pre>');
  20.    response.end();
  21. });
  22.  
  23.  
  24. // socket.io goes below
  25.  
  26. var io = require('socket.io').listen(app, {     <-------------------- ERROR 1
  27.    log: true,
  28.    origins: '*:*'
  29. });
  30.  
  31. io.set('transports', [            <--------------------------------ERROR 2
  32.    // 'websocket',
  33.    'xhr-polling',
  34.    'jsonp-polling'
  35. ]);
  36.  
  37. var channels = {};
  38.  
  39. io.sockets.on('connection', function (socket) {
  40.    var initiatorChannel = '';
  41.    if (!io.isConnected) {
  42.        io.isConnected = true;
  43.    }
  44.  
  45.    socket.on('new-channel', function (data) {
  46.        if (!channels[data.channel]) {
  47.            initiatorChannel = data.channel;
  48.        }
  49.  
  50.        channels[data.channel] = data.channel;
  51.        onNewNamespace(data.channel, data.sender);
  52.    });
  53.  
  54.    socket.on('presence', function (channel) {
  55.        var isChannelPresent = !! channels[channel];
  56.        socket.emit('presence', isChannelPresent);
  57.    });
  58.  
  59.    socket.on('disconnect', function (channel) {
  60.        if (initiatorChannel) {
  61.            delete channels[initiatorChannel];
  62.        }
  63.    });
  64. });
  65.  
  66. function onNewNamespace(channel, sender) {
  67.    io.of('/' + channel).on('connection', function (socket) {
  68.        var username;
  69.        if (io.isConnected) {
  70.            io.isConnected = false;
  71.            socket.emit('connect', true);
  72.        }
  73.  
  74.        socket.on('message', function (data) {
  75.            if (data.sender == sender) {
  76.                if(!username) username = data.data.sender;
  77.  
  78.                socket.broadcast.emit('message', data.data);
  79.            }
  80.        });
  81.  
  82.        socket.on('disconnect', function() {
  83.            if(username) {
  84.                socket.broadcast.emit('user-left', username);
  85.                username = null;
  86.            }
  87.        });
  88.    });
  89. }
  90.  
  91. // run app
  92.  
  93. app.listen(process.env.PORT || 9559);
  94.  
  95. process.on('unhandledRejection', (reason, promise) => {
  96.  process.exit(1);
  97. });
  98.  
  99. console.log('Please open SSL URL: https://localhost:'+(process.env.PORT || 9559)+'/');
  100.  
2  Programación / Desarrollo Web / Ayuda. getelementbyid() no encuentra el nodo. en: 1 Julio 2020, 12:50 pm
Buenas a todos.

Estoy intentando automatizar una pagina con greasemonkey, en la cual tengo que hacer un click.

Intendo obtener el div con getelementbyid() pero no lo encuentra y al mirar el inspector de codigo de firefox si esta el id.

Este es el codigo de la pagina que aparece en el inspector de codigo:


Código:
<div id="interContainer" style="left: 0px; top: 174px; visibility: visible;">

<div class="headerbar">

<a href="#" onclick="javascript:interstitialBox.closeit(); return false">

<img src="/pop/closeit.gif" style="border: 0" title="Close Box"></a>

</div>

</div>

Cualquier ayuda vendra bien
3  Programación / Scripting / NODEJS (Obtener acceso a la cam, getUserMedia ) AYUDA en: 30 Octubre 2019, 15:31 pm

Este codigo me funciona en localhost, pero cuando intento entrar desde otro ordenador no funciona, no pide acceso a la camara. Aver si me podeis ayudar

El codigo pide acceso a la cam para luego enviar los frames por socket







Código:
<title>Streamer</title>

</head>

<body>

 

    holaaa

    <video autoplay></video>

 

 

    <script>

        // get video dom element

        const video = document.querySelector('video');

 

        // request access to webcam

        navigator.mediaDevices.getUserMedia({video: {width: 426, height: 240}}).then((stream) => video.srcObject = stream);

 

        // returns a frame encoded in base64

        const getFrame = () => {

            const canvas = document.createElement('canvas');

            canvas.width = video.videoWidth;

            canvas.height = video.videoHeight;

            canvas.getContext('2d').drawImage(video, 0, 0);

            const data = canvas.toDataURL('image/png');

            return data;

        }

        const WS_URL = "ws://192.168.0.112:3000";

        const FPS = 3;

        const ws = new WebSocket(WS_URL);

        ws.onopen = () => {

            console.log(`Connected to ${WS_URL}`);

            setInterval(() => {

                //ws.send(getFrame());

            }, 1000 / FPS);

        }

    </script>

</body>

</html>
4  Programación / PHP / Busco consejo. ( Es buena idea usar php como cliente socket?) en: 17 Julio 2017, 23:59 pm
Buenas a todos.
Les cuento, quiero crear un servidor socket con php para una pagina web y no se que es lo que seria
mejor para el cliente, si php o websocket o que.

Espero vuestros consejos.
5  Sistemas Operativos / Windows / Consulta sobre Windows Multipoint Server - Es obligatorio el zero client? en: 27 Octubre 2016, 18:06 pm


Mi pregunta es si hace falta el zero client o se puede montar simplemente con los usb y el hdmi
de mi PC


Gracias de antemano.
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines