blob: 4a56085bd84129cbe7f32b3e237263102957349b (
plain) (
tree)
|
|
defmodule SApp.Chat do
def send(msg) do
msgitem = {(System.os_time :seconds),
Shard.Identity.get_nickname(),
msg}
GenServer.cast(SApp.Chat.Log, {:insert, msgitem})
SNet.ConnSupervisor
|> DynamicSupervisor.which_children
|> Enum.each(fn {_, pid, _, _} -> GenServer.cast(pid, :init_push) end)
end
def msg_callback({ts, nick, msg}) do
IO.puts "#{ts |> DateTime.from_unix! |> DateTime.to_iso8601} <#{nick}> #{msg}"
end
def msg_cmp({ts1, nick1, msg1}, {ts2, nick2, msg2}) do
SData.MerkleList.cmp_ts_str({ts1, nick1<>"|"<>msg1},
{ts2, nick2<>"|"<>msg2})
end
end
|