Permalink
Browse files

Only decode packet types we're interested in.

  • Loading branch information...
1 parent 33938a3 commit 3087d3de7b6ff6a63852a86b2e3187e305b32ae8 @archaelus committed Mar 18, 2012
Showing with 9 additions and 6 deletions.
  1. +9 −6 src/enet_codec.erl
View
@@ -58,12 +58,15 @@ module(_) -> {error, unknown_packet_type}.
decode(Type, Data, Options) ->
TypesToDecode = proplists:get_value(decode_types, Options, [Type]),
- true = TypesToDecode =:= all orelse lists:member(Type, TypesToDecode),
- {Mod, MOpts} = mod_options(Type, Options),
- true = Mod =/= error,
- case Mod:decode(Data, MOpts) of
- {error, _} -> Data;
- Decoded -> Decoded
+ case TypesToDecode =:= all orelse lists:member(Type, TypesToDecode) of
+ true ->
+ {Mod, MOpts} = mod_options(Type, Options),
+ true = Mod =/= error,
+ case Mod:decode(Data, MOpts) of
+ {error, _} -> Data;
+ Decoded -> Decoded
+ end;
+ false -> Data
end.
encode(Type, Data, Options) ->

0 comments on commit 3087d3d

Please sign in to comment.