update README

This commit is contained in:
Philipp Kunz 2016-08-15 03:47:32 +02:00
parent 475cd12904
commit 87cc238345

View File

@ -21,16 +21,15 @@ let mySocketRole = new smartsocket.SocketRole({
passwordHash: "someHashedString" passwordHash: "someHashedString"
}); });
let mySocketFunction = new smartsocket.SocketFunction({ let testSocketFunction1 = new smartsocket.SocketFunction({
name:"newService", funcName:"testSocketFunction1",
func:(data) => { funcDef:(data) => {
}, the function to execute }, // the function to execute
roles:[mySocketRole] // all roles that have access to a specific function allowedRoles:[mySocketRole] // all roles that have access to a specific function
}); });
mySmartsocket.registerRole(mySocketRole); mySmartsocket.clientCall("","restart",data,someTargetConnection)
mySmartsocket.clientCall.select("client1","restart",data)
.then((responseData) => { .then((responseData) => {
}); });
@ -40,28 +39,38 @@ mySmartsocket.clientCall.select("client1","restart",data)
```typescript ```typescript
import * as smartsocket from "smartsocket"; import * as smartsocket from "smartsocket";
let mySmartsocketClient = new smartsocket.SmartsocketClient({ let testSmartsocketClient = new smartsocket.SmartsocketClient({
url: "somedomain.com", // url, note: will only work over https, no http supported. port: testConfig.port,
port: 3000 url: "http://localhost",
role:"dockerhost", // some role, in this example a dockerhost vm, password: "testPassword",
password:"somePassword", alias: "testClient1",
alias:"client1" role: "testRole1"
});
testSmartsocketClient.connect()
.then(() => {
done();
});
let testSocketFunction2 = new smartsocket.SocketFunction({
funcName: "testSocketFunction2",
funcDef: (data) => {}, // the function to execute, has to return promise
allowedRoles:[]
}); });
let mySocketFunction2 = new smartsocket.SocketFunction({ let functionCalldata = {
name:"restart", funcName: "",
func:(data) => {}, the function to execute funcData: {
}); someKey:"someValue"
}
}
mySmartsocketClient.registerFunction(mySocketFunction2); mySmartsocketClient.serverCall("function",functionCallData)
.then((functionResponseData) => { // the functionResponseData comes from the server... awesome, right?
mySmartsocketClient.serverCall("newService",data)
.then((responseData) => {
});; });;
``` ```
> **NOTE:** > **NOTE:**
you can easily chain dependent requests on eiter the server or client side with promises. you can easily chain dependent requests on either the server or client side with promises.
`data` is always a js object that you can design for your specific needs. `data` is always a js object that you can design for your specific needs.
It supports buffers for large binary data network exchange. It supports buffers for large binary data network exchange.