-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Janus SDK #347
Closed
Closed
Implement Janus SDK #347
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Introduces `Connection` class to handle WebSocket connections. * Defines connection states (connecting, connected, closing, closed) and exposes getters. * Implements event listeners for connection state changes and messages. * Creates `TransactionManager` class to manage transactions over the connection. * Enables queuing transactions when the connection is unavailable. * Binds `TransactionManager` to the `Connection` for message handling. This commit is part of a major change to support reliable communication and transaction management.
* Introduces `isSipError`, `isSipHangupEvent`, `isSIPIncomingCallMessage`, `isSIPCallAcceptedEvent`, and `isSipRingingEvent` functions in `janus.ts` to identify specific Janus response types for SIP events. * Adds a `deferredPromise` function in `promise.ts` to create deferred promises for asynchronous operations. These functions enhance code readability and provide flexible promise control for improved message and task management.
* Includes eventemitter3 for event management within the connection class. This dependency provides a robust event system for the WebSocket connection.
* Introduces `KeepAliveAgent` class to maintain connection health. * Utilizes `Connection` and `transactionManager` for communication. * Sends periodic keep-alive transactions (default 10 seconds) to the server. * Monitors connection state and restarts keep-alive on reconnection. * Implements failure handling with a configurable retry mechanism. This feature ensures the connection remains active and facilitates reliable communication.
* Introduces `SIPRegistrationAgent` class to handle SIP registration. * Interacts with `Connection`, `transactionManager`, and `Handler` for communication. * Manages registration state (`unregistered`, `registering`, `registered`, `error`). * Sends SIP registration transactions using `transactionManager`. * Handles registration responses, updating state and triggering events. * Implements error handling and signaling through events. * Includes a placeholder for `unregister()` for future implementation. This feature enables automatic SIP registration with error handling and event notifications.
* Introduces `Call` class to represent SIP calls. * Manages call states (new, connecting, ringing, active, held, done). * Handles incoming and outbound call scenarios. * Provides methods for answering, hanging up, and getting call stats (placeholder). * Includes functionality for setting Telnyx call control IDs. feat: implement call-agent for handling sip call interactions * Introduces `CallAgent` class for managing SIP call flow. * Creates and manages `Call` instances for incoming and outgoing calls. * Interacts with `Connection`, `Peer`, `TransactionManager`, and `Handler`. * Handles incoming call events (`SIPIncomingCallMessage`). * Handles SIP hangup events (`JanusSIPHangupEvent`). * Handles SIP call accepted events (`JanusSIPCallAcceptedEvent`). * Triggers events (`SwEvent.Notification`) for call updates. * Implements audio handling for ringtones and ringback tones. feat: Implement Peer class for WebRTC peer connections * Introduces `Peer` class to handle WebRTC peer connections for calls. * Supports creating offer and answer peers based on call options. * Handles local media stream acquisition with constraints. * Manages adding media tracks to the peer connection. * Provides methods for handling ICE trickles and negotiation needed events. * Implements methods for setting remote SDP and closing the connection. * Triggers events (`SwEvent.MediaError`) for media acquisition failures. feat: Implement ICETrickleTransaction for sending ICE candidates * Introduces `ICETrickleTransaction` to send ICE candidates to Janus. * Constructs a Janus `trickle` request with candidate information. * Handles success and error responses from Janus on message received. feat: Implement SIPAnswerTransaction for sending SIP answer * Introduces `SIPAnswerTransaction` for sending SIP answer messages. * Constructs a Janus `message` request with answer SDP and other details. * Handles success (`isSIPCallAcceptedEvent`) and error (`isSipError`) responses. * Resolves with call ID on successful SIP answer reception. feat: Implement SIPCallTransaction for initiating SIP calls * Introduces `SIPCallTransaction` for initiating SIP calls via Janus. * Constructs a Janus `message` request with call details, URI, and SDP. * Handles success (`isSipRingingEvent`) and error (`isSipError`) responses. * Resolves with call ID, Telnyx IDs, on successful SIP call initiation. feat: Implement SIPHangupTransaction for terminating SIP calls * Introduces `SIPHangupTransaction` for sending SIP hangup messages. * Constructs a Janus `message` request with the hangup request. * Handles success (`janus === ack`) and error (`janus === error`) responses. * Resolves with `true` on successful SIP hangup.
* Introduces JanusClient class as the central component for SIP calls. * Manages connection to Janus server, plugin attachment, and SIP registration. * Handles call creation and management through CallAgent. * Provides methods for connecting, making calls, getting calls, and setting remote media element. * Includes event handling for listening to call events. * Implements stubs for enabling/disabling webcam and disconnection (to be completed). BREAKING CHANGE: Introduces a new class for core functionality, potentially affecting code organization and usage.
farhat-ha
requested review from
DeividVeloso,
a team,
ericaprieto,
lmao12,
jonathan-telnyx and
priscillasantana
March 11, 2024 22:05
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://telnyx.atlassian.net/browse/TELAPPS-4802
This PR is easier to review by commit
Describe your changes
Impement janus client
📝 To Do
✋ Manual testing
🦊 Browser testing
Desktop
📸 Screenshots