Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing a comment in the composer.json file #4

Open
wants to merge 2 commits into
base: 3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function initialize() {
$this->loadComponent('Jsonrpc.Server', [
'listen' => array('example') // will process JSON-RPC requests sent to this action
]);
);
}
```

Once available, the server will now listen on the actions specified in the "listen" setting. When a call is made to one of these actions, and assuming no error occurs previously in the processing of the request, the call will be delegated to the controller method defined in the "method" property of the JSON request object. This method will receive a single argument, which is the JSON request object received by the server. The value returned by this method will be JSON encoded, and sent back to the client in the "result" property of the JSON response object.
Expand All @@ -44,7 +44,7 @@ public function user($request) {
} else {
throw new Exception('No user ID was specified', 123);
}
);
}
```

In order to send an error as the response you need only throw an *Exception* in your controller's method. This will be caught by the **Server** component and processed as a JSON error object.
Expand All @@ -65,9 +65,10 @@ From your actions you can now make requests using the **Client** component. To d
public function getUser() {
// create a JSON request object
$request = $this->Client->createJsonRequest('user', array('userId' => 7));
// send the request to the server and return the result

// send the request to the server and return the result
return $this->Client->sendJsonRequest($request, array('host' => 'example.com', 'path' => '/api/call'));
);
}
```

Keep in mind that if a JSON error object is returned from the server this will be thrown as a *CakeException* in your application.
Expand All @@ -82,9 +83,10 @@ public function getAllTheThings() {
$this->Client->createJsonRequest('jacket', array('jacketId' => 55)),
$this->Client->createJsonRequest('shoes', array('shoesId' => 73))
);

// send the array of requests to the server and return the results as an array
return $this->Client->sendJsonRequest($batch);
);
}
```

When sending batch requests, if one of the request returns a JSON error object a *CakeException* will not be thrown, as the error object is returned within the array. Also, be aware that the order of the JSON response objects may not be coherent with the order of the requests sent, so always use the ID to determine the response corresponding with your request.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"require": {
"php": ">=5.3.0",
"composer/installers": "*",
"jakeasmith/http_build_url": "^1" // To allow/enable http_build_url
"jakeasmith/http_build_url": "^1"
},
"extra": {
"installer-name": "Jsonrpc"
Expand Down