graze / guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle
https://packagist.org/packages/graze/guzzle-jsonrpc
MIT License
93 stars 61 forks source link

EventDispatcher problem #1

Closed krasun closed 10 years ago

krasun commented 10 years ago

Hi, first of all, thank you for your implementation of JSON-RPC for Guzzle.

I had some problems with it, specially with EventDispatcher. I think when your create your Request type, you must set to it EventDispatcher from client:

// path/to/vendor/Graze/Guzzle/JsonRpc/Message/Request.php

public function __construct(RequestInterface $request, $method, $id = null)
    {
        parent::__construct($request->getMethod(), $request->getUrl(), $request->getHeaders());

        $this->setClient($request->getClient());
        // this fixes the problem
        $this->setEventDispatcher($request->getClient()->getEventDispatcher());
        $this->rpcFields = new Collection(array(
            'jsonrpc' => JsonRpcClientInterface::VERSION,
            'method'  => (string) $method
        ));

        if (null !== $id) {
            $this->setRpcField('id', $id);
        }
    }

I had problems when used MisdGuzzleBundle. This bundle allows to log requests, but it does not work with your client, because it has not correct EventDispatcher.

adlawson commented 10 years ago

Thanks for alerting us to this, @krasun! This coming Monday, I'll try to replicate this issue and write some tests around it. Hopefully you should see a fix merged in shortly after.

I'll keep up updated.

krasun commented 10 years ago

@adlawson, thank you for quick feedback.

adlawson commented 10 years ago

@krasun sorry it took me so long to fix!

krasun commented 10 years ago

@adlawson, oh, it's OK. Maybe, I had to fix it and do pull request, instead of creating issue and steal your time ;) Thank you!