File tree Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Expand file tree Collapse file tree 1 file changed +5
-20
lines changed Original file line number Diff line number Diff line change @@ -23,27 +23,12 @@ defmodule ExWebRTC.ICECandidate do
23
23
end
24
24
25
25
@ spec from_json ( % { String . t ( ) => String . t ( ) | non_neg_integer ( ) | nil } ) :: t ( )
26
- def from_json (
27
- % {
28
- "candidate" => c ,
29
- "sdpMid" => mid ,
30
- "sdpMLineIndex" => mline_idx
31
- } = json
32
- ) do
33
- from_json ( Map . put ( json , "usernameFragment" , nil ) )
34
- end
35
-
36
- def from_json ( % {
37
- "candidate" => c ,
38
- "sdpMid" => mid ,
39
- "sdpMLineIndex" => mline_idx ,
40
- "usernameFragment" => ufrag
41
- } ) do
26
+ def from_json ( json ) when is_map ( json ) do
42
27
% __MODULE__ {
43
- candidate: c ,
44
- sdp_mid: mid ,
45
- sdp_m_line_index: mline_idx ,
46
- username_fragment: ufrag
28
+ candidate: Map . fetch! ( json , "candidate" ) ,
29
+ sdp_mid: Map . fetch! ( json , "sdpMid" ) ,
30
+ sdp_m_line_index: Map . fetch! ( json , "sdpMLineIndex" ) ,
31
+ username_fragment: Map . get ( json , "usernameFragment" )
47
32
}
48
33
end
49
34
end
You can’t perform that action at this time.
0 commit comments