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

node.js bug with slow socket release workaround #119

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.idea/
node-xmlrpc.iml
/nbproject
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.11"
- "0.12"
- "4.0"
- "4.1"
- "4.2"
- "5.0"
- "5.1"
- "5.2"
- "5.3"
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,14 @@ server.on('NotFound', function(method, params) {
console.log('Method ' + method + ' does not exist');
})
// Handle method calls by listening for events with the method call name
server.on('anAction', function (err, params, callback) {
server.on('anAction', function (err, params, callback, request, response) {
console.log('Method call params for \'anAction\': ' + params)

// ...perform an action...

// Use request and response objects directly for any custom processing, e.g.
// set or forward cookies

// Send a method response with a value
callback(null, 'aResult')
})
Expand Down Expand Up @@ -177,6 +180,71 @@ var client = xmlrpc.createClient('YOUR_ENDPOINT');
client.methodCall('YOUR_METHOD', [new YourType(yourVariable)], yourCallback);
```

### XML RPC Error
There is a special error type defined - `XmlRpcError`. And a helper function makeError to create errors easily.
Use it to create an error and pass it to the `callback`.

```javascript
// Makes an error with only message and code defaults to zero (0)
xmlrpc.makeError("Error occured")
```

The resulting response would be:
```xml
<?xml version="1.0"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>code</name>
<value>
<int>0</int>
</value>
</member>
<member>
<name>message</name>
<value>
<string>Error occured</string>
</value>
</member>
</struct>
</value>
</fault>
</methodResponse>
```

The error with a code example:
```javascript
// Makes an error with message and code
xmlrpc.makeError("Error occured", 123)
```

The resulting response would be:
```xml
<?xml version="1.0"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value>
<int>123</int>
</value>
</member>
<member>
<name>faultString</name>
<value>
<string>Error occured</string>
</value>
</member>
</struct>
</value>
</fault>
</methodResponse>
```

### To Debug (client-side)

Error callbacks on the client are enriched with request and response
Expand Down
Loading