voxnix 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@ A React Component SDK for seamless Voice PABX Integration.
4
4
 
5
5
  ## Overview
6
6
 
7
- Voxnix is a ready-to-use SDK designed to quickly integrate voice and PABX calling features into your React applications. It provides a self-contained dialer UI and automatically handles voice engine connectivity, including remote media stream attachment and cleanup for Sip.js.
7
+ Voxnix is a ready-to-use SDK designed to quickly integrate voice and PABX calling features into your React applications. It provides a self-contained dialer UI and automatically handles voice engine connectivity, including remote media stream attachment.
8
8
 
9
9
  ## Installation
10
10
 
@@ -19,8 +19,8 @@ yarn add voxnix
19
19
  You can use the `Voxnix` component directly in your React application. Pass the required PABX configuration credentials through the `config` prop and use the event callbacks to listen for call states. You can also use a React `ref` to imperatively control the call (e.g., answer, hold, mute, hangup) from your parent component.
20
20
 
21
21
  ```jsx
22
- import React, { useRef } from 'react';
23
- import { Voxnix } from 'voxnix';
22
+ import React, { useRef } from "react";
23
+ import { Voxnix } from "voxnix";
24
24
 
25
25
  const App = () => {
26
26
  const voxnixRef = useRef(null);
@@ -29,39 +29,40 @@ const App = () => {
29
29
  auth: {
30
30
  username: "YOUR_USERNAME",
31
31
  password: "YOUR_PASSWORD",
32
- host: "YOUR_PABX_HOST" // e.g., sip.example.com
33
- }
32
+ host: "YOUR_PABX_HOST", // e.g., sip.example.com
33
+ },
34
34
  };
35
35
 
36
36
  const handleIncomingCall = (callData) => {
37
- console.log('Incoming call notification:', callData);
37
+ console.log("Incoming call notification:", callData);
38
38
  // You can answer programmatically
39
39
  // voxnixRef.current.answer();
40
40
  };
41
41
 
42
42
  const handleCallAnswered = () => {
43
- console.log('Call has been answered');
43
+ console.log("Call has been answered");
44
44
  };
45
45
 
46
46
  const handleCallEnded = () => {
47
- console.log('Call has ended');
47
+ console.log("Call has ended");
48
48
  };
49
49
 
50
50
  const handleRegisterStatus = (status) => {
51
- console.log('PABX Registration Status:', status); // "REGISTERED" | "FAILED"
51
+ console.log("PABX Registration Status:", status); // "REGISTERED" | "FAILED"
52
52
  };
53
53
 
54
54
  // Example Call Controls
55
55
  const toggleMute = (isMuted) => voxnixRef.current?.mute(isMuted);
56
- const toggleHold = (isOnHold, setIsOnHold) => voxnixRef.current?.hold(isOnHold, setIsOnHold);
56
+ const toggleHold = (isOnHold, setIsOnHold) =>
57
+ voxnixRef.current?.hold(isOnHold, setIsOnHold);
57
58
  const endCall = () => voxnixRef.current?.hangup();
58
59
 
59
60
  return (
60
- <div style={{ padding: '20px' }}>
61
+ <div style={{ padding: "20px" }}>
61
62
  <h1>Voice Integration App</h1>
62
-
63
+
63
64
  {/* Voxnix Voice Engine & UI Component */}
64
- <Voxnix
65
+ <Voxnix
65
66
  ref={voxnixRef}
66
67
  config={pabxConfig}
67
68
  onIncomingCall={handleIncomingCall}
@@ -78,28 +79,28 @@ export default App;
78
79
 
79
80
  ## Component Props
80
81
 
81
- | Prop | Type | Description |
82
- |------|------|-------------|
83
- | `config` | `Object` | Configuration object containing `auth` credentials (`username`, `password`, `host`). |
84
- | `onIncomingCall` | `Function` | Callback triggered when there is an incoming call. |
85
- | `onCallAnswered` | `Function` | Callback triggered when the call is answered. |
86
- | `onCallEnded` | `Function` | Callback triggered when the call ends. |
87
- | `onCallUnanswered` | `Function` | Callback triggered when an incoming call is not answered. |
88
- | `onRegisterStatus` | `Function` | Callback triggered when the PABX registration status changes. |
82
+ | Prop | Type | Description |
83
+ | ------------------ | ---------- | ------------------------------------------------------------------------------------ |
84
+ | `config` | `Object` | Configuration object containing `auth` credentials (`username`, `password`, `host`). |
85
+ | `onIncomingCall` | `Function` | Callback triggered when there is an incoming call. |
86
+ | `onCallAnswered` | `Function` | Callback triggered when the call is answered. |
87
+ | `onCallEnded` | `Function` | Callback triggered when the call ends. |
88
+ | `onCallUnanswered` | `Function` | Callback triggered when an incoming call is not answered. |
89
+ | `onRegisterStatus` | `Function` | Callback triggered when the PABX registration status changes. |
89
90
 
90
91
  ## Ref API (Call Controls)
91
92
 
92
93
  You can access these methods by passing a `ref` to the `Voxnix` component:
93
94
 
94
- | Method | Parameters | Description |
95
- |--------|------------|-------------|
96
- | `answer()` | - | Answers an incoming call. |
97
- | `reject()` | - | Rejects an incoming call. |
98
- | `hangup()` | - | Ends the current active call. |
99
- | `mute(isMuted)` | `isMuted: boolean` | Mutes or unmutes the local microphone. |
95
+ | Method | Parameters | Description |
96
+ | ----------------------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
97
+ | `answer()` | - | Answers an incoming call. |
98
+ | `reject()` | - | Rejects an incoming call. |
99
+ | `hangup()` | - | Ends the current active call. |
100
+ | `mute(isMuted)` | `isMuted: boolean` | Mutes or unmutes the local microphone. |
100
101
  | `hold(isOnHold, setIsOnHold)` | `isOnHold: boolean, setIsOnHold: function` | Puts the call on hold or resumes it. Passes `setIsOnHold` to allow the SDK to asynchronously update the parent UI state when the re-INVITE succeeds. |
101
102
 
102
- ## Media Handling (Sip.js)
103
+ ## Media Handling
103
104
 
104
105
  Voxnix handles remote media setup automatically. When a call state becomes `Established`, Voxnix will attach the incoming audio stream to an invisible `<audio id="voxnix-remote-audio" />` element. When the call is terminated, the media is safely cleaned up.
105
106