aboutsummaryrefslogtreecommitdiff
path: root/lib/app
diff options
context:
space:
mode:
Diffstat (limited to 'lib/app')
-rw-r--r--lib/app/chat.ex21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/app/chat.ex b/lib/app/chat.ex
new file mode 100644
index 0000000..4a56085
--- /dev/null
+++ b/lib/app/chat.ex
@@ -0,0 +1,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