An open API service indexing awesome lists of open source software.

https://github.com/kocyigitkim/realtime.io

Real time data streaming & socket programming library
https://github.com/kocyigitkim/realtime.io

data realtime socket streaming

Last synced: 11 months ago
JSON representation

Real time data streaming & socket programming library

Awesome Lists containing this project

README

          

# Introduction
Real time data streaming & socket programming library

# Getting Started
Steps:
1. Installation
2. Software dependencies
3. Usage

# 1. Installation

- npm install realtime.io
- yarn add realtime.io

# 2. Software dependencies
- socket.io
- socket.io-client
- uuid
- chalk
- crypto
- express
- http
- node-cache
# 3. Usage

##### A. _How To Create & Listen Server_
```js
// Import RealTime.IO Library
const realtimeio = require('realtime.io');
// Define Server Options
// You can inspect server options from library
const serverOptions = new realtimeio.server.RealtimeIOServerOptions();
// Create RealTime Server
const server = new realtimeio.server.RealtimeIOServer(serverOptions);
// Listen
server.listen();
```
##### B. _How To Define Server Object_
```js
class NotificationServerObject extends realtimeio.server.RealtimeIOServerObject{
constructor(server){
super('notification', server);
}
Listener_showNotification(client, type, title, message){
console.log(['Type: ', type, 'Title: ', title, 'Message: ', message].join(' '));
}
}
```
##### C. How To Use Notification Server Object ?
```js
// Listen
server.listen();
// Write this code after listen server expression
const notificationServer = new NotificationServerObject(server);
```
Then everything will be nice :)

##### D. How To Create Client ?
```js
// Import RealTime.IO Library
const realtimeio = require('realtime.io');
// Define Client Options
// You can inspect client options from library
const clientOptions = new realtimeio.server.RealtimeIOClientOptions();
// Create RealTime Client
const client = new realtimeio.client.RealtimeIOClient(clientOptions);
// Connect to server
client.connect();
```
##### E. How To Define Client Object?
```js
class NotificationClientObject extends realtimeio.client.RealtimeIOClientObject{
constructor(client){
super('notification', client);
}
showNotification(type, title, message){}
}
```
##### F. How To Send A New Notification ?
```js
// Connect to server
client.connect();
// Send new notification
const notificationObject = new NotificationClientObject(client);
notificationObject.showNotification('info', 'Example #1', 'Hello world :)');
```