Created
February 28, 2010 01:18
-
-
Save maluta/317100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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