React-Sockets
Manage sockets connection easily with the react power, is how a orm but of sockets :)
General Schema
How to install?
npm install --save reactsockets
Accepts protocols
WebSockets Socket.IO (Develop phase)
WebSockets Implementation
Required params
- Protocol
- ws or wss
- Host / Ip
- Port
Config params
- KeysTrust
- List of keys that are used to decode the message and update the react state
Example
// Imports;; { // Parent superprops; // State thisstate = message: '' ; // Sockets config thisprotocol = 'ws'; thishost = 'localhost'; thisport = 8080; // KeysTrust this; } // Render component { return <div id="chat-input">thisstatemessage</div> ; } ;
SocketIO Implementation
Required params
- Url
- Server url
Config params
- KeysTrust
- List of keys that are used to decode the message and update the react state
Example
// Imports;; { // Parent superprops; // State thisstate = message: '' ; // Sockets config thisurl = 'http://localhost:8080'; // KeysTrust this; } // Render component { return <div id="chat-input">thisstatemessage</div> ; } ;
KeysTrust
The parametter 'keytrust' must a be an array of strings or array strings/objects
Example
const keysTrust = 'name' messages: 'storage' ;
Why objects?
With a object you are define type of keys, type are: - Storage - All values with this keys are save in a array - Increment - Increment previous value with the new received value - Decrement - Decrement previous value with the new received value