From e1dbdc1a15b1cd1bd86d3b7b139f9e05dfa42e02 Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Mon, 26 Sep 2016 00:28:39 +0200 Subject: [PATCH] improve README --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1d45174..b0ffaff 100644 --- a/README.md +++ b/README.md @@ -25,22 +25,22 @@ Under the hood we use socket.io and shortid for managed data exchange. import * as smartsocket from "smartsocket"; import * as q from q // q is a promise library -// The smartsocket listens on a port and can receive new socketconnection requests. +// The "Smartsocket" listens on a port and can receive new "SocketConnection" requests. let mySmartsocket = new smartsocket.Smartsocket({ port: 3000 // the port smartsocket will listen on }); -// A socket role can be referenced by SocketFunctions. -// All SocketRequests carry authentication data for a specific role. -// SocketFunctions now which roles are allowed to execute them +// A "SocketRole" can be referenced by "SocketFunction"s. +// All "SocketRequest"s carry authentication data for a specific "SocketRole". +// "SocketFunction"s know which "SocketRole"s are allowed to execute them let mySocketRole = new smartsocket.SocketRole({ name: "someRoleName", passwordHash: "someHashedString" }); -// A SocketFunction executes a referenced function and passes in any data of the corresponding request. -// The referenced function must return a promise and resolve with any data -// Any request will be carries a unique identifier. If the referenced function's promise resolved any passed on argument will be returned to the requesting party +// A "SocketFunction" executes a referenced function and passes in any data of the corresponding "SocketRequest". +// The referenced function must return a promise and resolve with data of type any. +// Any "SocketRequest" carries a unique identifier. If the referenced function's promise resolved any passed on argument will be returned to the requesting party let testSocketFunction1 = new smartsocket.SocketFunction({ funcName:"testSocketFunction1", funcDef:(data) => { @@ -49,10 +49,10 @@ let testSocketFunction1 = new smartsocket.SocketFunction({ allowedRoles:[mySocketRole] // all roles that have access to a specific function }); -// A smartsocket exposes a .clientCall() that gets -// 1. the name of the SocketFunctin on the client side +// A "Smartsocket" exposes a .clientCall() that gets +// 1. the name of the "SocketFunction" on the client side // 2. the data to pass in -// 3. And a target connection (there can be multiple connections at once) +// 3. And a target "SocketConnection" (there can be multiple connections at once) // any unique id association is done internally mySmartsocket.clientCall("restart",data,someTargetConnection) .then((responseData) => { @@ -64,8 +64,8 @@ mySmartsocket.clientCall("restart",data,someTargetConnection) ```typescript import * as smartsocket from "smartsocket"; -// A SmartsocketClient is different from a Smartsocket in that it doesn't expose any public address -// Thus any new connections must be innitiated from the client +// A "SmartsocketClient" is different from a "Smartsocket" in that it doesn't expose any public address. +// Thus any new "SocketConnection"s must be innitiated from a "SmartsocketClient". let testSmartsocketClient = new smartsocket.SmartsocketClient({ port: testConfig.port, url: "http://localhost", @@ -74,13 +74,13 @@ let testSmartsocketClient = new smartsocket.SmartsocketClient({ role: "testRole1" }); -// You can .connect() and .disconnect() from a Smartsocket +// You can .connect() and .disconnect() from a "Smartsocket" testSmartsocketClient.connect() .then(() => { done(); }); -// The client can also specify SocketFunctions. It can also specify Roles in case a client connects to multiple servers at once +// The client can also specify "SocketFunction"s. It can also specify "SocketRole"s in case a client connects to multiple servers at once let testSocketFunction2 = new smartsocket.SocketFunction({ funcName: "testSocketFunction2", funcDef: (data) => {}, // the function to execute, has to return promise @@ -88,7 +88,7 @@ let testSocketFunction2 = new smartsocket.SocketFunction({ }); -// A SmartsocketClient can call functions on the serverside using .serverCall() analog to the Smartsocket's .clientCall method. +// A "SmartsocketClient" can call functions on the serverside using .serverCall() analog to the "Smartsocket"'s .clientCall method. mySmartsocketClient.serverCall("function",functionCallData) .then((functionResponseData) => { // the functionResponseData comes from the server... awesome, right?