Skip to content

Instantly share code, notes, and snippets.

@maluta
Created February 28, 2010 01:18
Show Gist options
  • Save maluta/317100 to your computer and use it in GitHub Desktop.
Save maluta/317100 to your computer and use it in GitHub Desktop.
-module(m).
-export([start/0,ui_recvMessage/2,open/0,validate/2]).
start() ->
io:format("Starting message~n").
ui_recvMessage(Api_token,Message) ->
io:format("Received:~n token=~w Message=~w~n",[Api_token,Message]),
case Message of
"open" -> io:format("lets call open()~n"),
Open_PID = spawn(m, open, []),
spawn(m, validate, [Open_PID,Api_token]),
io:format("PID ~w~n",[Open_PID]);
"save" -> io:format("lets call save()~n")
end.
open() ->
io:format("function open started~n"),
receive
open_ok ->
io:format("open successful ~n", []);
open_error ->
io:format("something wrong ~n", [])
end.
validate(PID,Token) ->
io:format("function validated started and waiting... ~n"),
if
Token == 12345 ->
PID ! open_ok;
Token /= 12345 ->
PID ! open_error
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment