balena / elixir-sippet

An Elixir library designed to be used as SIP protocol middleware.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sample MyCore implementation

IvanRibakov opened this issue · comments

Could you please provide a sample MyCore implementation? Reason I'm asking is that I've done all other configuration/setup (as explained in the readme) and I'm able to see started plug 127.0.0.1:5060/udp logged message when I start the application, however none of the log messages from my custom core implementation appear when I send a sample INVITE request.

For the reference - my custom core implementation:

defmodule ZCore do
  require Logger
  alias Sippet.Transactions
  alias Sippet.Message

  @behaviour Sippet.Core

  require Logger


  @impl Sippet.Core
  def receive_request(req, serverTxKey) do
    Logger.debug(fn -> "#{inspect self()} receive_request:: req => #{inspect req}; serverTxKey => #{inspect serverTxKey}" end)
    req |> Message.to_response(100) |> Transactions.send_response(serverTxKey)
  end

  @impl Sippet.Core
  def receive_response(resp, clientTxKey) do
    Logger.debug(fn -> "#{inspect self()} receive_response:: resp => #{inspect resp}; clientTxKey => #{inspect clientTxKey}" end)
  end

  @impl Sippet.Core
  def receive_error(reason, txKey) do
    Logger.debug(fn -> "#{inspect self()} receive_error:: reason => #{inspect reason}; txKey => #{inspect txKey}" end)
  end

end

As you might have guessed - an Elixir beginner here so any other relevant comments/suggestions are welcome.

Hi @IvanRibakov .

In principle I don't see any problem with your implementation. By the way, I would check your configurations in config/config.exs. In special, double check if you connected your Core to the solution. You should have the following on your configuration file:

# Configures the sippet core
config :sippet, Sippet.Core, ZCore

As an alternative, you can check https://github.com/balena/elixir-sippet-proxy . It is another library that uses elixir-sippet to build a SIP proxy. It contains a Sippet.Core implementation and that could be a good start point for your implementation.

(...)

Ah, I just checked. The https://github.com/balena/elixir-sippet-proxy code lacks a working config/config.exs configuration. Basically you need a

# Configures the sippet core
config :sippet, Sippet.Core, Sippet.Proxy.Core

To make it start working.

Closing this issue due to inactivity. Please open a new issue if the problem persists.