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
def application do | |
[mod: {AcmeUdpLogger, []}, | |
applications: [:logger]] | |
end |
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
defmodule AcmeUdpLoggerTest.MessageReceiver do | |
use ExUnit.Case | |
@header <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2>> | |
@priority_code <<81>> | |
@agent_number <<7, 0, 0, 0>> | |
@message <<116, 104, 101, 32, 104, 101, 110, 32, 104, 97, 115, 32, 102, 108, 111, 119, 110, 32, 116, 104, 101, 32, 99, 111, 111, 112, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32>> | |
test "it should extract relevant data from UDP packet" do | |
packet = @header <> @priority_code <> @agent_number <> @message |
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
defmodule AcmeUdpLogger.MessageReceiver do | |
use GenServer | |
require Logger | |
def start_link(opts \\ []) do | |
GenServer.start_link(__MODULE__, :ok, opts) | |
end | |
def init (:ok) do | |
{:ok, _socket} = :gen_udp.open(21337) |
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
defmodule AcmeUdpLogger.MessageReceiver do | |
use GenServer | |
def start_link(opts \\ []) do | |
GenServer.start_link(__MODULE__, :ok, opts) | |
end | |
def init (:ok) do | |
{:ok, _socket} = :gen_udp.open(21337) | |
end |
NewerOlder