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

https://github.com/simplisticated/recognizer-for-node

Socket recognizer for Node.js
https://github.com/simplisticated/recognizer-for-node

Last synced: 12 months ago
JSON representation

Socket recognizer for Node.js

Awesome Lists containing this project

README

          











## At a Glance

`Recognizer` identifies users connected to your server with socket. The library is built on top of [Socket.IO](https://socket.io).

## How to Get Started

If you use `npm`, type in Terminal:

```
npm install --save @imatyushkin/recognizer socket.io
npm install --save-dev @types/socket.io
```

If you prefer `yarn`, type:

```
yarn add @imatyushkin/recognizer socket.io
yarn add @types/socket.io --dev
```

## Usage

`Recognizer` requires SocketIO server instance:

```typescript
const recognizer = new Recognizer({
socketIO: ,
users: {
onAdded: (user) => {
// Handle new user
},
onEvent: (user, event, data) => {
// Handle event from user
},
onRemoved: (user) => {
// Handle user's removal
}
}
});
```

To add new user, simply send socket to recognizer:

```typescript
recognizer.add(socket);
```

To remove the user, write this:

```typescript
recognizer.remove(socket);
```

## License

`Recognizer` is available under the Apache 2.0 license. See the [LICENSE](./LICENSE) file for more info.