# rs-chat

> Rs chat is a node.js realtime chat moduel and javascript plugin

Latest version **2.0.7** (published 2019-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install rs-chat
pnpm add rs-chat
yarn add rs-chat
bun add rs-chat
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2019-04-06 |
| First published | 2018-12-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | ravi shukla |
| Maintainers | ravishkl5 |
| Keywords | chat, nodejs, node, javascript, socket.io |

## Links

- npm: https://www.npmjs.com/package/rs-chat
- Repository: https://github.com/ravishukla007/chat
- Homepage: https://github.com/ravishukla007/chat#readme
- Issues: https://github.com/ravishukla007/chat/issues
- npm.io page: https://npm.io/package/rs-chat

## Dependencies (2)

- [mysql](https://npm.io/package/mysql.md) ^2.16.0
- [socket.io](https://npm.io/package/socket.io.md) ^2.1.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.0.7 (latest) — 2019-04-06
- 2.0.6 — 2019-03-30
- 2.0.5 — 2019-03-30
- 2.0.4 — 2019-01-12
- 2.0.3 — 2019-01-12
- 2.0.2 — 2019-01-12
- 2.0.1 — 2019-01-12
- 1.0.7 — 2018-12-12
- 1.0.5 — 2018-12-12
- 1.0.4 — 2018-12-12
- 1.0.3 — 2018-12-08
- 1.0.2 — 2018-12-08
- 1.0.1 — 2018-12-06
- 1.0.0 — 2018-12-05

## README

## Live Demo ##

[https://rs-chat-demo.herokuapp.com](https://rs-chat-demo.herokuapp.com)


## Demo Gif Image ##

![Demo Gif](https://drive.google.com/uc?export=view&id=148aArRyQoN4Jg6-HpXCs6pEwL67H-mAu)

## Youtube Instalation Guide ##

[![Youtube Instalation Guide](http://img.youtube.com/vi/TGWlZkFIuV8/0.jpg)](https://www.youtube.com/watch?v=TGWlZkFIuV8 "Youtube Instalation Guide")

## Getting started ##

### Get a copy of the plugin ###

You can install it through npm.
 
```js
$ npm install rs-chat
```

### Setup for nodejs ###

Open index.js file and put the below code and start nodejs server

```js
var app = require('http')
var chat = require('rs-chat')(app);

chat.init({
  host     : 'localhost', // DB host
  user     : 'user', // DB User
  password : 'password', // DB Password
  database : 'database', // DB Name
  assets   : 'assets' // assets path
});

```

### Create table ### 

```js
CREATE TABLE `messages` (
  `id` int(11) NOT NULL,
  `userId` int(11) NOT NULL,
  `toId` int(11) NOT NULL,
  `msg` mediumtext COLLATE utf8mb4_bin NOT NULL,
  `type` int(1) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0 / null = text, 1 = image, 2=video',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `read_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;


```

### Load the required files ### 

Inside the page's head tag include the CSS file.

```js
<link rel="stylesheet" type="text/css" href="https://unpkg.com/rs-chat@2.0.7/dist/rs-chat.min.css">
```

In the page's footer, just before &lt;/body&gt;, include the required JavaScript files.

```js
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>

<script type="text/javascript" src="https://unpkg.com/rs-chat@2.0.7/dist/rs-chat.min.js"></script>

```

### Instantiate the chat plugin ### 

```js
<script type="text/javascript">
  RSChat.init({
    socketUrl: 'http://localhost:8080/' // server url,
    userId: '1', // logged in user id
    name: 'ravi shukla', // logged in user name
  });
</script>
```


### Call the below function to open chat box ### 

```js
RSChat.start('user_id', 'username')
```


## Global Settings

S.No|Options|Type|Purpuse
---|---|---|---
1|emoji(optional)|Bool|Enable emoji feature or not
3|iconSize(optional)|Integer|Emoji size
2|media(optional)|Bool|Enable / Disable media
4|assetPath|String|Asset path for the media
6|supportedFile(optional)|Array|Supported media file
5|invalidFileMessage(optional)|String|Message on wrong media file
7|perPage(optional)|Integer|Pagination for the chat list
8|marginRight(optional)|Integer|Margin for each chat window
9|beforeDialogOpen(optional)|Promise|Callback before chat box open
10|maxFileSize(optional)|Integer|Max file size to upload default 1MB
11|maxFileSizeError(optional)|String|Error message on big media file


### Support ###

If you found a bug please submit it in the Issues.

If you need help with implementing the chat in your project, You can mail me at ravishkl5@gmail.com

### Suggestion ###

If you have any suggestion, You can write mail to me at ravishkl5@gmail.com

---
_Source: https://npm.io/package/rs-chat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
