Skip to content

Instantly share code, notes, and snippets.

@jakewilson801
Created September 8, 2015 06:45
Show Gist options
  • Select an option

  • Save jakewilson801/96b222feb84724e3bca2 to your computer and use it in GitHub Desktop.

Select an option

Save jakewilson801/96b222feb84724e3bca2 to your computer and use it in GitHub Desktop.
-module(bot).
-behaviour(gen_server).
-export([start_link/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
start_link() ->
gen_server:start_link({local,?MODULE},?MODULE, [], []).
init([]) -> {ok, []}.
handle_call(Message, _From, State) ->
case Message of
{hi, Msg} ->
{reply, {"nice to meet you ", Msg}, State};
{bye, Msg} ->
{reply, {"see you later ", Msg}, State};
_ ->
{reply, {"I dont understand", Message}, State}
end.
handle_cast(r, s) ->
{noreply,r}.
handle_info(Msg, state) ->
{noreply, Msg}.
terminate(normal, state) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
@jakewilson801

Copy link
Copy Markdown
Author
c(bot). bot:start_link(). gen_server:call(bot, {hi, "Jake"}). gen_server:call(bot, {bye, "Jake"}). gen_server:call(bot, "sending not a tuple 2 without hi/bye").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment