Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
Enviar mensaje a un usuario de registro específico desde la base de datos mysql ratchet php

Estoy tratando de crear herramientas de mensajería en mi aplicación. Estoy atascado en Cómo enviar un mensaje a un usuario de registro específico. Obtención de la base de datos. Soy nuevo en websocket ratchet.

Quiero crear algo como Fiverr, upwork chat donde el cliente pueda contactar a los vendedores.

aquí está mi código

índice.html

 <html> <head> <style> input, button { padding: 10px; } </style> </head> <body> <input type="text" id="message" autocomplete="off" /> <button onclick="transmitMessage()">Send</button> <script> // Create a new WebSocket. var socket = new WebSocket('ws://localhost:8080?value=450'); // Define the var message = document.getElementById('message'); function transmitMessage() { socket.send( message.value ); } socket.onmessage = function(e) { document.getElementById('ids').innerHTML= e.data; } </script> <div id="ids"></div> </body> </html>

enchufe.php

 namespace MyApp; use Ratchet\MessageComponentInterface; use Ratchet\ConnectionInterface; class Socket implements MessageComponentInterface { public function __construct() { $this->clients = new \SplObjectStorage; } public function onOpen(ConnectionInterface $conn) { // Store the new connection in $this->clients $this->clients->attach($conn); echo "New connection! ({$conn->resourceId})\n"; } public function onMessage(ConnectionInterface $from, $msg) { foreach ( $this->clients as $client ) { if ( $from->resourceId == $client->resourceId ) { continue; } $client->send( "Client $from->resourceId said $msg" ); } } public function onClose(ConnectionInterface $conn) { } public function onError(ConnectionInterface $conn, \Exception $e) { } }
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda