Permalink
Browse files

can parse amf3, binary version of amf_requets.xml

  • Loading branch information...
1 parent 651e86d commit 0b861f10f528f6bbd302f3923026f924902167a5 @trung committed Oct 2, 2009
Showing with 7 additions and 2 deletions.
  1. +7 −2 temp/server/amf3.erl
View
@@ -29,6 +29,7 @@ reset() ->
clear(TableName) ->
try ets:delete_all_objects(TableName) of
true ->
+ _ = ets:insert(TableName, {counter, 0}),
{ok}
catch
error:Error ->
@@ -49,18 +50,22 @@ sure_exist(TableName) ->
%% wrapper of ets:insert, just make sure the table exists
insert(TableName, Obj) ->
_ = sure_exist(TableName),
- {ok, {counter, Count}} = read(TableName, counter),
+ {ok, Count} = read(TableName, counter),
io:fwrite("Inserting into ~p - index: ~p - value: ~p ~n", [TableName, Count, Obj]),
_ = ets:insert(TableName, {Count, Obj}),
_ = ets:insert(TableName, {counter, Count+1}),
{ok, inserted, Count}.
%% wrapper of ets:lookup
read(TableName, Ref) ->
+ io:fwrite("Read from ~p with index ~p got value ", [TableName, Ref]),
case ets:lookup(TableName, Ref) of
[] ->
{bad, {not_found, TableName, Ref}};
- [Obj|_] ->
+ [{counter, Count}|_] ->
+ {ok, Count};
+ [{_Idx, Obj}|_] ->
+%% io:fwrite("~p~n", [Obj]),
{ok, Obj}
end.

0 comments on commit 0b861f1

Please sign in to comment.