<?php

namespace Cadoles\WebsocketBundle\Service;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Doctrine\ORM\EntityManager;

class messageService
{  
    protected $container;
    protected $em;
    protected $activate_websocket;

    public function __construct($container, EntityManager $em, $activate_websocket)
    {
        $this->container = $container;
        $this->em = $em;
        $this->activate_websocket = $activate_websocket;
    }

    public function send($key,$userid,$groupid,$message) {
        $pusher = $this->container->get('gos_web_socket.wamp.pusher');
        $pusher->push(['mykey' => $key, 'type' => 'add', 'message' => $message], 'websocket_topic', ['group' => $groupid]); 
        $pusher->push(['userid' => $userid, 'type' => 'add', 'group' => $groupid], 'websocket_counter'); 
    }
}
