<div dir="ltr">
        <br>
        




            
            

<div>I am trying to update my process's state on a 3 second timer.<br><div class="gmail-post-text"><pre class="gmail-lang-erlang gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-kwd">-define</span><span class="gmail-pln">(</span><span class="gmail-typ">INTERVAL</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-lit">3000</span><span class="gmail-pln">)</span><span class="gmail-pun">.</span><span class="gmail-pln">

start_link() ->
    gen_server:start_link(</span><span class="gmail-lit">?MODULE,</span><span class="gmail-pln"> []</span><span class="gmail-pun">,</span><span class="gmail-pln"> [])</span><span class="gmail-pun">.</span><span class="gmail-pln">

action(</span><span class="gmail-typ">Pid</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">Action</span><span class="gmail-pln">) ->
  gen_server:</span><span class="gmail-kwd">call</span><span class="gmail-pln">(</span><span class="gmail-typ">Pid</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">Action</span><span class="gmail-pln">)</span><span class="gmail-pun">.</span><span class="gmail-pln">

init([]) -> 
  erlang:send_after(</span><span class="gmail-lit">?INTERVAL,</span><span class="gmail-pln"> self()</span><span class="gmail-pun">,</span><span class="gmail-pln"> trigger)</span><span class="gmail-pun">,</span><span class="gmail-pln">
  {ok</span><span class="gmail-pun">,</span><span class="gmail-pln"> temple:new()}</span><span class="gmail-pun">.</span></code></pre>

<p>what I want to do is call this</p>

<pre class="gmail-lang-erlang gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln">handle_call({fight}</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">_From</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">Temple</span><span class="gmail-pln">) ->
  </span><span class="gmail-typ">NewTemple</span><span class="gmail-pln"> = temple:fight(</span><span class="gmail-typ">Temple</span><span class="gmail-pln">)</span><span class="gmail-pun">,</span><span class="gmail-pln">
  {reply</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">NewTemple</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">NewTemple</span><span class="gmail-pln">}</span><span class="gmail-pun">;</span></code></pre>

<p>So I try</p>

<pre class="gmail-lang-erlang gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln">handle_info(trigger</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">_State</span><span class="gmail-pln">) ->
   land:action(self()</span><span class="gmail-pun">,</span><span class="gmail-pln"> {fight})</span><span class="gmail-pun">,</span><span class="gmail-pln">
   erlang:send_after(</span><span class="gmail-lit">?INTERVAL,</span><span class="gmail-pln"> self()</span><span class="gmail-pun">,</span><span class="gmail-pln"> trigger)</span><span class="gmail-pun">;</span></code></pre>

<p>but I get</p>

<pre class="gmail-lang-erlang gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln">=</span><span class="gmail-typ">ERROR</span><span class="gmail-pln"> </span><span class="gmail-typ">REPORT</span><span class="gmail-pln">==== </span><span class="gmail-lit">4</span><span class="gmail-pln">-</span><span class="gmail-typ">Dec</span><span class="gmail-pln">-</span><span class="gmail-lit">2016</span><span class="gmail-pln">::</span><span class="gmail-lit">19</span><span class="gmail-pln">:</span><span class="gmail-lit">00</span><span class="gmail-pln">:</span><span class="gmail-lit">35</span><span class="gmail-pln"> ===
** </span><span class="gmail-typ">Generic</span><span class="gmail-pln"> server <</span><span class="gmail-lit">0.400</span><span class="gmail-pun">.</span><span class="gmail-lit">0</span><span class="gmail-pln">> terminating
** </span><span class="gmail-typ">Last</span><span class="gmail-pln"> message </span><span class="gmail-kwd">in</span><span class="gmail-pln"> was trigger
** </span><span class="gmail-typ">When</span><span class="gmail-pln"> </span><span class="gmail-typ">Server</span><span class="gmail-pln"> state == {{dict</span><span class="gmail-pun">,</span><span class="gmail-lit">0</span><span class="gmail-pun">,</span><span class="gmail-lit">16</span><span class="gmail-pun">,</span><span class="gmail-lit">16</span><span class="gmail-pun">,</span><span class="gmail-lit">8</span><span class="gmail-pun">,</span><span class="gmail-lit">80</span><span class="gmail-pun">,</span><span class="gmail-lit">48</span><span class="gmail-pun">,</span><span class="gmail-pln">
                               {[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">
                                []}</span><span class="gmail-pun">,</span><span class="gmail-pln">
                               {{[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">
                                 []}}}</span><span class="gmail-pun">,</span><span class="gmail-pln">
                         []}
** </span><span class="gmail-typ">Reason</span><span class="gmail-pln"> for termination ==
** {function_clause</span><span class="gmail-pun">,</span><span class="gmail-pln">[{land</span><span class="gmail-pun">,</span><span class="gmail-pln">terminate</span><span class="gmail-pun">,</span><span class="gmail-pln">
                           [{timeout</span><span class="gmail-pun">,</span><span class="gmail-pln">{gen_server</span><span class="gmail-pun">,</span><span class="gmail-kwd">call</span><span class="gmail-pun">,</span><span class="gmail-pln">[<</span><span class="gmail-lit">0.400</span><span class="gmail-pun">.</span><span class="gmail-lit">0</span><span class="gmail-pln">></span><span class="gmail-pun">,</span><span class="gmail-pln">{fight}]}}</span><span class="gmail-pun">,</span><span class="gmail-pln">
                            {{dict</span><span class="gmail-pun">,</span><span class="gmail-lit">0</span><span class="gmail-pun">,</span><span class="gmail-lit">16</span><span class="gmail-pun">,</span><span class="gmail-lit">16</span><span class="gmail-pun">,</span><span class="gmail-lit">8</span><span class="gmail-pun">,</span><span class="gmail-lit">80</span><span class="gmail-pun">,</span><span class="gmail-lit">48</span><span class="gmail-pun">,</span><span class="gmail-pln">
                                   {[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">
                                    []</span><span class="gmail-pun">,</span><span class="gmail-pln">[]}</span><span class="gmail-pun">,</span><span class="gmail-pln">
                                   {{[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">
                                     []</span><span class="gmail-pun">,</span><span class="gmail-pln">[]</span><span class="gmail-pun">,</span><span class="gmail-pln">[]}}}</span><span class="gmail-pun">,</span><span class="gmail-pln">
                             []}]</span><span class="gmail-pun">,</span><span class="gmail-pln">
                           [{file</span><span class="gmail-pun">,</span><span class="gmail-str">"src/land.erl"</span><span class="gmail-pln">}</span><span class="gmail-pun">,</span><span class="gmail-pln">{line</span><span class="gmail-pun">,</span><span class="gmail-lit">47</span><span class="gmail-pln">}]}<br><br><br></span></code></pre><pre class="gmail-lang-erlang gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-pln">What am I missing here?<br></span></code></pre>
    </div></div></div>