1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
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
|