aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/net/tcpconn.ex
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-10-12 22:39:38 +0200
committerAlex Auvolat <alex@adnab.me>2018-10-12 22:39:38 +0200
commit0ed802601812acd6ad764e6ffd5aacfd7e674553 (patch)
tree1b7fccb7fbf81a6822dd3313f00a940e441b90ed /shard/lib/net/tcpconn.ex
parenteab3f9483b3659b1ad3572393d24652cac71c8b6 (diff)
downloadshard-0ed802601812acd6ad764e6ffd5aacfd7e674553.tar.gz
shard-0ed802601812acd6ad764e6ffd5aacfd7e674553.zip
Connection management improvement, stuff
Diffstat (limited to 'shard/lib/net/tcpconn.ex')
-rw-r--r--shard/lib/net/tcpconn.ex5
1 files changed, 5 insertions, 0 deletions
diff --git a/shard/lib/net/tcpconn.ex b/shard/lib/net/tcpconn.ex
index bd169aa..7025ffe 100644
--- a/shard/lib/net/tcpconn.ex
+++ b/shard/lib/net/tcpconn.ex
@@ -296,6 +296,11 @@ defmodule SNet.TCPConn do
{:noreply, %{state | nonce_send: next_nonce(state.nonce_send) }}
end
+ def handle_cast(:close, state) do
+ Logger.info "Closing: #{print_id state} at #{inspect state.peer_info}"
+ exit(:normal)
+ end
+
def handle_info({:tcp, _socket, raw_data}, state) do
{:ok, msgbin} = :enacl.secretbox_open(raw_data, state.nonce_recv, state.secret_recv)
msg_data = :erlang.binary_to_term(msgbin, [:safe])