From befe82feaab706f808c8c56cc9cee84577483fdc Mon Sep 17 00:00:00 2001 From: Pascal Benoit Date: Fri, 5 Mar 2021 09:59:17 +0100 Subject: [PATCH 1/4] Add the trickle ICE implementation and check the length of sendMsg to not send ACK event because is an empty event --- janus.go | 9 ++++++++- types.go | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/janus.go b/janus.go index 09d4cc0..3a8c131 100644 --- a/janus.go +++ b/janus.go @@ -120,7 +120,14 @@ func (gateway *Gateway) send(msg map[string]interface{}, transaction chan interf } func passMsg(ch chan interface{}, msg interface{}) { - ch <- msg + jsonbody, err := json.Marshal(msg) + if err != nil { + fmt.Println(err) + return + } + if len(string(jsonbody)) > 2 { + ch <- msg + } } func (gateway *Gateway) ping() { diff --git a/types.go b/types.go index 74c2a5a..86b19cd 100644 --- a/types.go +++ b/types.go @@ -20,6 +20,7 @@ package janus var msgtypes = map[string]func() interface{}{ + "trickle": func() interface{} { return &TrickleMsg{} }, "error": func() interface{} { return &ErrorMsg{} }, "success": func() interface{} { return &SuccessMsg{} }, "detached": func() interface{} { return &DetachedMsg{} }, @@ -40,6 +41,17 @@ type BaseMsg struct { Handle uint64 `json:"sender"` } +type TrickleMsg struct { + Candidate Candidate `json:"candidate"` +} + +type Candidate struct { + Completed bool `json:"completed"` + SdpMid *string `json:"sdpMid"` + SdpMLineIndex *uint16 `json:"sdpMLineIndex"` + Candidate string `json:"candidate"` +} + type ErrorMsg struct { Err ErrorData `json:"error"` } From 9c379cb0d38c17904b26e37a1be0c7f038c0daab Mon Sep 17 00:00:00 2001 From: Pascal Benoit Date: Mon, 14 Jun 2021 18:06:23 +0200 Subject: [PATCH 2/4] accept ack msg --- .idea/.gitignore | 8 +++++ .idea/janus-go.iml | 9 +++++ .idea/misc.xml | 87 ++++++++++++++++++++++++++++++++++++++++++++++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ janus.go | 7 ---- 6 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/janus-go.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..1ef2006 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../:\git\janus-go\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/janus-go.iml b/.idea/janus-go.iml new file mode 100644 index 0000000..5e764c4 --- /dev/null +++ b/.idea/janus-go.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..3090cb4 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5d237cc --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/janus.go b/janus.go index 3a8c131..61a4cee 100644 --- a/janus.go +++ b/janus.go @@ -120,14 +120,7 @@ func (gateway *Gateway) send(msg map[string]interface{}, transaction chan interf } func passMsg(ch chan interface{}, msg interface{}) { - jsonbody, err := json.Marshal(msg) - if err != nil { - fmt.Println(err) - return - } - if len(string(jsonbody)) > 2 { ch <- msg - } } func (gateway *Gateway) ping() { From 4654b4844bba86f01810944b8de2c31b1234c181 Mon Sep 17 00:00:00 2001 From: Pascal Benoit Date: Tue, 15 Jun 2021 10:54:44 +0200 Subject: [PATCH 3/4] close the chan on the trickle --- janus.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/janus.go b/janus.go index 61a4cee..2b8437a 100644 --- a/janus.go +++ b/janus.go @@ -469,16 +469,16 @@ func (handle *Handle) Trickle(candidate interface{}) (*AckMsg, error) { req, ch := newRequest("trickle") req["candidate"] = candidate handle.send(req, ch) - - msg := <-ch + close(ch) + /*msg := <-ch switch msg := msg.(type) { case *AckMsg: return msg, nil case *ErrorMsg: return nil, msg } - - return nil, unexpected("trickle") +*/ + return nil, nil } // TrickleMany sends a trickle request to the Gateway as part of establishing From cec237f7a7c08c1147888adfe7afc5203878941c Mon Sep 17 00:00:00 2001 From: Pascal Benoit Date: Tue, 15 Jun 2021 11:18:39 +0200 Subject: [PATCH 4/4] send ack back is ok on the trickle --- .idea/.gitignore | 8 ----- .idea/janus-go.iml | 9 ----- .idea/misc.xml | 87 ---------------------------------------------- .idea/modules.xml | 8 ----- .idea/vcs.xml | 6 ---- janus.go | 8 ++--- 6 files changed, 4 insertions(+), 122 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/janus-go.iml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 1ef2006..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Datasource local storage ignored files -/../../../../:\git\janus-go\.idea/dataSources/ -/dataSources.local.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/janus-go.iml b/.idea/janus-go.iml deleted file mode 100644 index 5e764c4..0000000 --- a/.idea/janus-go.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 3090cb4..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 5d237cc..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/janus.go b/janus.go index 2b8437a..61a4cee 100644 --- a/janus.go +++ b/janus.go @@ -469,16 +469,16 @@ func (handle *Handle) Trickle(candidate interface{}) (*AckMsg, error) { req, ch := newRequest("trickle") req["candidate"] = candidate handle.send(req, ch) - close(ch) - /*msg := <-ch + + msg := <-ch switch msg := msg.(type) { case *AckMsg: return msg, nil case *ErrorMsg: return nil, msg } -*/ - return nil, nil + + return nil, unexpected("trickle") } // TrickleMany sends a trickle request to the Gateway as part of establishing