# Jellyfish Elixir Server SDK

[![API Docs](](

Elixir server SDK for [Jellyfish](
Currently it allows for:

- making API calls to Jellyfish server (QoL wrapper for HTTP requests)
- listening to Jellyfish server events via WebSocket

## Installation

The package can be installed by adding `jellyfish_server_sdk` to your list of dependencies in `mix.exs`:

def deps do
    {:jellyfish_server_sdk, "~> 0.5.0"}

## Jellyfish connection configuration

Define the connection configuration in the mix config,
specifying server address and authentication token
(for more information see [Jellyfish docs](
``` config.exs
config :jellyfish_server_sdk,
  server_address: "localhost:5002",
  server_api_token: "your-jellyfish-token",
  secure?: true

Alternatively, the connection options can be provided when creating a `Jellyfish.Client` or starting `Jellyfish.WSNotifier`:

client = "localhost:5002", server_api_token: "your-jellyfish-token")

{:ok, notifier} =
      server_address: "localhost:5002",
      server_api_token: "your-jellyfish-token"

## Usage

Make API calls to Jellyfish and receive server events:

# start process responsible for receiving events
{:ok, notifier} = Jellyfish.WSNotifier.start()
:ok = Jellyfish.WSNotifier.subscribe_server_notifications(notifier)

# create HTTP client instance
client =

# Create room
{:ok, %Jellyfish.Room{id: room_id}, jellyfish_address} = Jellyfish.Room.create(client, max_peers: 10)

# => "8878cd13-99a6-40d6-8d7e-8da23d803dab"

# Add peer
{:ok, %Jellyfish.Peer{id: peer_id}, peer_token} =
    Jellyfish.Room.add_peer(client, room_id, Jellyfish.Peer.WebRTC)

receive do
  {:jellyfish, %Jellyfish.Notification.PeerConnected{room_id: ^room_id, peer_id: ^peer_id}} ->
    # handle the notification

# Delete peer
:ok = Jellyfish.Room.delete_peer(client, room_id, peer_id)

List of structs representing events can be found in the [docs](

## Testing

When calling `mix test` it will automatically start the Jellyfish 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](

[![Software Mansion](](

Licensed under the [Apache License, Version 2.0](LICENSE)