From 52a3ed7c5700fa398efb8a4aff9d586a850e3d58 Mon Sep 17 00:00:00 2001 From: Simponic Date: Sat, 31 Dec 2022 16:32:56 -0700 Subject: Better logging, close previous sessions once session threshold has been reached --- lib/chessh/ssh/client.ex | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'lib/chessh/ssh/client.ex') diff --git a/lib/chessh/ssh/client.ex b/lib/chessh/ssh/client.ex index 35893f1..eba188f 100644 --- a/lib/chessh/ssh/client.ex +++ b/lib/chessh/ssh/client.ex @@ -1,16 +1,27 @@ defmodule Chessh.SSH.Client do - alias Chessh.SSH.Client + alias IO.ANSI require Logger use GenServer - # TODO: tui_state_stack is like [:menu, :player_settings, :change_password] or [:menu, {:game, game_id}, {:game_chat, game_id}] + @default_message [ + ANSI.clear(), + ANSI.reset(), + ANSI.home(), + ["Hello, world"] + ] - defstruct [:tui_pid, :width, :height, :player_id, :tui_state_stack] + defmodule State do + defstruct tui_pid: nil, + width: nil, + height: nil, + player_session: nil, + state_statck: [] + end @impl true - def init([tui_pid, width, height] = args) do - Logger.debug("#{inspect(args)}") - {:ok, %Client{tui_pid: tui_pid, width: width, height: height}} + def init([%State{tui_pid: tui_pid} = state]) do + send(tui_pid, {:send_data, @default_message}) + {:ok, state} end end -- cgit v1.3