From 80311e3b4f60bd1c2484ac2d5b77c1f376dfa94d Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 24 Oct 2015 17:38:04 +0200 Subject: Add dispatch --- tda.erl | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'tda.erl') diff --git a/tda.erl b/tda.erl index 3cc89e8..027efbd 100644 --- a/tda.erl +++ b/tda.erl @@ -118,17 +118,14 @@ loop(Sock) -> end. decode(Sock, Msg) -> - case rose:decode('ROS', Msg) of - {ok, Rose} -> + case dispatch(Msg) of + rose -> + {ok, Rose} = rose:decode('ROS', Msg), rose_handler(Sock, Rose), io:format("ROSE> ~p~n", [Rose]); - {error, _} -> - case acse:decode('ACSE-apdu', Msg) of - {ok, Acse} -> - io:format("ACSE> ~p~n", [Acse]); - {error, _} -> - io:format(">>> ~p~n", [Msg]) - end + acse -> + {ok, Acse} = acse:decode('ACSE-apdu', Msg), + io:format("ACSE> ~p~n", [Acse]) end. rose_handler(Sock, {invoke, Rose}) -> @@ -146,3 +143,13 @@ invoke_handler(#'Invoke'{invokeId = {present, Id}, opcode = {local, Op}}) -> end end. +dispatch(<>) -> + case H of + 96 -> acse; + 97 -> acse; + 98 -> acse; + 99 -> acse; + 100 -> acse; + 161 -> rose; + 162 -> rose + end. -- cgit v1.2.3