Basic routing + account creation
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
defmodule NeonVertigoService.MessageProcessor do
|
||||
@ets_auctions NeonVertigoService.Auctions
|
||||
@ets_bids NeonVertigoService.Bids
|
||||
|
||||
def init_tables() do
|
||||
@ets_auctions = :ets.new(@ets_auctions, [:named_table])
|
||||
@ets_bids = :ets.new(@ets_bids, [:named_table])
|
||||
:ok
|
||||
end
|
||||
|
||||
def process_message(["auctions", "create"], payload, _properties) do
|
||||
gid = payload["gid"]
|
||||
data = Map.take(payload, ["author_gid", "min_bet"]) |> Enum.map(fn {k, v} -> {String.to_atom(k), v} end) |> Map.new
|
||||
{min_bet, _} = Decimal.parse(data[:min_bet])
|
||||
data = Map.put(data, :min_bet, min_bet)
|
||||
:ets.insert_new(@ets_auctions, {gid, data})
|
||||
:noreply
|
||||
end
|
||||
|
||||
def process_message(_, _, _) do
|
||||
:noreply
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user