https://github.com/fishjam-dev/elixir_server_sdk
Elixir server SDK for Fishjam
https://github.com/fishjam-dev/elixir_server_sdk
elixir fishjam membrane-control video webrtc
Last synced: 20 days ago
JSON representation
Elixir server SDK for Fishjam
- Host: GitHub
- URL: https://github.com/fishjam-dev/elixir_server_sdk
- Owner: fishjam-dev
- License: apache-2.0
- Created: 2023-02-03T11:21:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-13T11:27:52.000Z (over 1 year ago)
- Last Synced: 2025-02-10T09:27:45.525Z (11 months ago)
- Topics: elixir, fishjam, membrane-control, video, webrtc
- Language: Elixir
- Homepage:
- Size: 6.25 MB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fishjam Elixir Server SDK
[](https://hex.pm/packages/fishjam_server_sdk)
[](https://hexdocs.pm/fishjam_server_sdk/)
[](https://codecov.io/gh/fishjam-dev/elixir_server_sdk)
[](https://circleci.com/gh/fishjam-dev/elixir_server_sdk)
Elixir server SDK for [Fishjam](https://github.com/fishjam-dev/fishjam).
Currently it allows for:
- making API calls to Fishjam server (QoL wrapper for HTTP requests)
- listening to Fishjam server events via WebSocket
## Installation
The package can be installed by adding `fishjam_server_sdk` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:fishjam_server_sdk, "~> 0.6.0"}
]
end
```
## Fishjam connection configuration
Define the connection configuration in the mix config,
specifying server address and authentication token
(for more information see [Fishjam docs](https://fishjam-dev.github.io/fishjam-docs/getting_started/authentication))
``` config.exs
config :fishjam_server_sdk,
server_address: "localhost:5002",
server_api_token: "your-fishjam-token",
secure?: true
```
Alternatively, the connection options can be provided when creating a `Fishjam.Client` or starting `Fishjam.WSNotifier`:
```elixir
client =
Fishjam.Client.new(server_address: "localhost:5002", server_api_token: "your-fishjam-token")
{:ok, notifier} =
Fishjam.WSNotifier.start(
server_address: "localhost:5002",
server_api_token: "your-fishjam-token"
)
```
## Usage
Make API calls to Fishjam and receive server events:
```elixir
# start process responsible for receiving events
{:ok, notifier} = Fishjam.WSNotifier.start()
:ok = Fishjam.WSNotifier.subscribe_server_notifications(notifier)
# create HTTP client instance
client = Fishjam.Client.new()
# Create room
{:ok, %Fishjam.Room{id: room_id}, fishjam_address} = Fishjam.Room.create(client, max_peers: 10)
room_id
# => "8878cd13-99a6-40d6-8d7e-8da23d803dab"
# Add peer
{:ok, %Fishjam.Peer{id: peer_id}, peer_token} =
Fishjam.Room.add_peer(client, room_id, Fishjam.Peer.WebRTC)
receive do
{:fishjam, %Fishjam.Notification.PeerConnected{room_id: ^room_id, peer_id: ^peer_id}} ->
# handle the notification
end
# Delete peer
:ok = Fishjam.Room.delete_peer(client, room_id, peer_id)
```
List of structs representing events can be found in the [docs](https://hexdocs.pm/fishjam_server_sdk).
## Testing
When calling `mix test` it will automatically start the Fishjam container under the hood.
Tests on CI are run with the use of docker-compose, to run it locally in the same way as on CI run `mix integration_test`.
## Copyright and License
Copyright 2023, [Software Mansion](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=fishjam)
[](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=fishjam)
Licensed under the [Apache License, Version 2.0](LICENSE)