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
- Host: GitHub
- URL: https://github.com/simplisticated/recognizer-for-node
- Owner: simplisticated
- License: apache-2.0
- Created: 2019-08-08T18:48:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-12T03:17:57.000Z (over 3 years ago)
- Last Synced: 2025-03-12T01:47:25.591Z (about 1 year ago)
- Language: TypeScript
- Size: 32.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.