# @veyetals/react-vitals-online

> React component for web version of veyetals utilizing webrtc

Latest version **1.0.14** (published 2023-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @veyetals/react-vitals-online
pnpm add @veyetals/react-vitals-online
yarn add @veyetals/react-vitals-online
bun add @veyetals/react-vitals-online
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.14 |
| Published | 2023-11-10 |
| First published | 2023-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 9 |
| Unpacked size | 6 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | hassanmarkitech |
| Keywords | veyetals, vitalsOnline, vitals-online, react-vitals-online |

## Links

- npm: https://www.npmjs.com/package/@veyetals/react-vitals-online
- Repository: /
- npm.io page: https://npm.io/package/@veyetals/react-vitals-online

## Dependencies (9)

- [sass](https://npm.io/package/sass.md) ^1.56.2
- [axios](https://npm.io/package/axios.md) ^1.4.0
- [react](https://npm.io/package/react.md) 16.12.0
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.1187.0
- [crypto-js](https://npm.io/package/crypto-js.md) ^4.1.1
- [face-api.js](https://npm.io/package/face-api.js.md) ^0.22.2
- [fetch-intercept](https://npm.io/package/fetch-intercept.md) ^2.4.0
- [amazon-cognito-identity-js](https://npm.io/package/amazon-cognito-identity-js.md) ^6.2.0
- [amazon-kinesis-video-streams-webrtc](https://npm.io/package/amazon-kinesis-video-streams-webrtc.md) ^2.0.4

## Recent versions

- 1.0.14 (latest) — 2023-11-10
- 1.0.13 — 2023-11-02
- 1.0.12 — 2023-11-01
- 1.0.11 — 2023-10-26
- 1.0.10 — 2023-10-20
- 1.0.9 — 2023-10-04
- 1.0.8 — 2023-10-02
- 1.0.7 — 2023-09-26
- 1.0.6 — 2023-09-25
- 1.0.5 — 2023-08-17
- 1.0.4 — 2023-07-27
- 1.0.3 — 2023-07-11
- 1.0.2 — 2023-06-20
- 1.0.1 — 2023-06-05
- 1.0.0 — 2023-06-01

## README

# react-vitals-online

> Made with create-react-library

[![NPM](https://img.shields.io/npm/v/@veyetals/react-vitals-online.svg)](https://www.npmjs.com/package/@veyetals/react-vitals-online) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install @veyetals/react-vitals-online
```

## Usage

**username:** username to authenticate user.

**password:** password to authenticate user.

**channelName:** Required\* Create Channel to connect to for video and veyetals scanning. Maximum length: 128 characters. May include numbers, letters, underscores (\_), and hyphens (-).

**application:** ie. 'veyetals'
        
**platform:** ie. 'ios'
    
**environment:** ie. 'prd' / 'stg'

**userType:** either 'master' or 'viewer.

**mode:** either 'video' or 'audio.

**onCallEnd:** Function to be called when user ends call.

**onVitalsCompleted:** Function to be called when veyetals is completed.

## useWebSocket

**isConnected:** indicates connection to socket - true or false

**connect:** function to connect to socket <sup>\*connection limit: 2 hrs</sup>

Arguments: userId

**callUser:** function to send info needed for a call

Arguments: userId, recipientId, channelName, mode

**answerCall:** function to notify caller of answer

Arguments: callerId, callerConnectionId, userId, answer

**socketMessage:** messages from socket

| function   | user      | description                        | socketMessage                                                                                                                        |
| ---------- | --------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| callUser   | caller    | recipient is not in db             | { status: 'callFailed', message: "recipientId not found" }                                                                           |
| callUser   | caller    | recipient is offline               | { status: 'callFailed', message: "recipientId is offline" }                                                                          |
| callUser   | recipient | recipient receives caller info     | { status: 'callIncoming', callerId: 'callerId', callerConnectionId: 'callerConnectionId', channelName: 'channelName', mode: 'mode' } |
| answerCall | recipient | caller is offline                  | { status: 'answerFailed', message: "recipientId is offline" }                                                                        |
| answerCall | caller    | caller receives answer from callee | { status: "answerToCall", recipientId: 'recipientId', answer: true \ false }                                                         |

## Example

```jsx
import React, { useState } from 'react'

import { VitalsOnline, useWebSocket } from '@veyetals/react-vitals-online'

import '@veyetals/react-vitals-online/dist/index.css'

export default function App() {
  const {
    isConnected,
    socketMessage,
    connect,
    disconnect,
    callUser,
    answerCall
  } = useWebSocket()

  const [active, setActive] = useState(false)

  const [username, setUsername] = useState('')
  const [password, setPassword] = useState('')
  const [channelName, setChannelName] = useState('testChannel')
  const [userType, setUserType] = useState('master')
  const [mode, setMode] = useState('video')

  const [callerId, setCallerId] = useState('')
  const [recipientId, setRecipientId] = useState('')
  const [callerConnectionId, setCallerConnectionId] = useState('')
  const [callAnswer, setCallAnswer] = useState('')

  const startMaster = () => {
    setUserType('master')
    setActive(true)
  }

  const startViewer = () => {
    setUserType('viewer')
    setActive(true)
  }

  // Callback function to receive the final reading from the component
  const handleVitalsCompleted = (vitals) => {
    console.log(vitals)
  }

  // Callback function for message from mobile call
  const handleOnMobileCall = (resp) => {
    console.log('handleOnMobileCall: ', resp)
  }

  useEffect(() => {
    console.log('socketMessage: ', socketMessage)
  }, [socketMessage])

  return (
    <div>
      <span>isConnected: {isConnected.toString()}</span>
      <button onClick={() => connect(username)}>Connect</button>
      <label>
        recipientId:
        <input
          type='text'
          value={recipientId}
          onChange={(e) => setRecipientId(e.target.value)}
        />
      </label>
      <button
        onClick={() => callUser(username, recipientId, channelName, mode)}
      >
        Call
      </button>
      <label>
        callerId:
        <input
          type='text'
          value={callerId}
          onChange={(e) => setCallerId(e.target.value)}
        />
      </label>
      <label>
        callerConnectionId:
        <input
          type='text'
          value={callerConnectionId}
          onChange={(e) => setCallerConnectionId(e.target.value)}
        />
      </label>
      <label>
        callAnswer:
        <input
          type='text'
          value={callAnswer}
          onChange={(e) => setCallAnswer(e.target.value)}
        />
      </label>
      <button
        onClick={() =>
          answerCall(callerId, callerConnectionId, username, callAnswer)
        }
      >
        answerCall
      </button>
      <button onClick={startMaster}>startMaster</button>;
      <button onClick={startViewer}>startViewer</button>;
      {active && (
        <VitalsOnline
          username={username}
          password={password}
          channelName={channelName}
          application={application}
          platform={platform}
          environment={environment}
          userType={userType}
          mode={mode}
          onCallEnd={() => setActive(false)}
          onMobileCall={handleOnMobileCall}
          onVitalsCompleted={handleVitalsCompleted}
        />
      )}
    </div>
  )
}
```

## License

MIT © [](https://github.com/)

---
_Source: https://npm.io/package/@veyetals/react-vitals-online · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
