<?php
  require '/usr/local/src/php/vendor/autoload.php';
  require './pusher.php';

  use Ratchet\ZMQ\Context;

  $loop   = React\EventLoop\Factory::create();
  $pusher = new Pusher;

  $context = new React\ZMQ\Context($loop);
  $pull = $context->getSocket(ZMQ::SOCKET_PULL);
  $pull->bind('tcp://127.0.0.1:8888'); // Binding to 127.0.0.1 means the only client that can connect is itself
  $pull->on('message', array($pusher, 'onBlogEntry'));

  /* ================================================================
  $context = new ZMQContext();
  $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'pusher');
  $socket->connect("tcp://localhost:8888");

  $socket->send("hello there!\n");
  */
?>
