3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
19 * @author Aaron Schulz
23 * Relayed that uses the mcrelaypushd server
25 class EventRelayerMCRD
extends EventRelayer
{
26 /** @var MultiHttpClient */
32 * Additional params include 'mcrdConfig', which is a map of:
33 * - url : The base URL of the service (without paths)
34 * @param array $params
36 public function __construct( array $params ) {
37 parent
::__construct( $params );
39 $this->baseUrl
= $params['mcrdConfig']['url'];
41 $httpConfig = isset( $params['httpConfig'] ) ?
$params['httpConfig'] : array();
42 if ( !isset( $httpConfig['connTimeout'] ) ) {
43 $httpConfig['connTimeout'] = 1;
45 if ( !isset( $httpConfig['reqTimeout'] ) ) {
46 $httpConfig['reqTimeout'] = .25;
49 $this->http
= new MultiHttpClient( $httpConfig );
52 protected function doNotify( $channel, array $events ) {
53 if ( !count( $events ) ) {
57 $response = $this->http
->run( array(
58 'url' => "{$this->baseUrl}/relayer/api/v1.0/" . rawurlencode( $channel ),
60 'body' => json_encode( array( 'events' => $events ) ),
61 'headers' => array( 'content-type' => 'application/json' )
64 return $response['code'] == 201;