From e5d97870a12ec87bd463b7657923bb79d3bcb4cc Mon Sep 17 00:00:00 2001 From: Logan Hunt Date: Tue, 31 Jan 2023 12:44:15 -0700 Subject: Rate limit game creation --- lib/chessh/ssh/client/client.ex | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lib/chessh/ssh/client/client.ex') diff --git a/lib/chessh/ssh/client/client.ex b/lib/chessh/ssh/client/client.ex index 67aa920..461dfbe 100644 --- a/lib/chessh/ssh/client/client.ex +++ b/lib/chessh/ssh/client/client.ex @@ -45,17 +45,20 @@ defmodule Chessh.SSH.Client do screen_state_initials: screen_state_initials } = state ) do - {:ok, new_screen_pid} = - GenServer.start_link(module, [%{screen_state_initial | client_pid: self()}]) + case GenServer.start_link(module, [%{screen_state_initial | client_pid: self()}]) do + {:ok, new_screen_pid} -> + send(new_screen_pid, {:render, width, height}) - send(new_screen_pid, {:render, width, height}) + {:noreply, + %State{ + state + | screen_pid: new_screen_pid, + screen_state_initials: [{module, screen_state_initial} | screen_state_initials] + }} - {:noreply, - %State{ - state - | screen_pid: new_screen_pid, - screen_state_initials: [{module, screen_state_initial} | screen_state_initials] - }} + _ -> + {:noreply, state} + end end @impl true -- cgit v1.2.3-70-g09d2