From df70a4461f594f3899c3434dea61dc76334fd739 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 7 Jun 2017 14:09:49 +0100 Subject: [PATCH] add `GET /_matrix/client/r0/voip/turnServer` Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- client.go | 8 ++++++++ responses.go | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/client.go b/client.go index 051c1f8..6f2a7ea 100644 --- a/client.go +++ b/client.go @@ -652,6 +652,14 @@ func (cli *Client) Messages(roomID, from, to string, dir rune, limit int) (resp return } +// TurnServer returns turn server details and credentials for the client to use when initiating calls. +// See http://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-voip-turnserver +func (cli *Client) TurnServer() (resp *RespTurnServer, err error) { + urlPath := cli.BuildURL("voip", "turnServer") + _, err = cli.MakeRequest("GET", urlPath, nil, &resp) + return +} + func txnID() string { return "go" + strconv.FormatInt(time.Now().UnixNano(), 10) } diff --git a/responses.go b/responses.go index 58191bc..1b9b066 100644 --- a/responses.go +++ b/responses.go @@ -162,3 +162,10 @@ type RespSync struct { } `json:"invite"` } `json:"rooms"` } + +type RespTurnServer struct { + Username string `json:"username"` + Password string `json:"password"` + TTL int `json:"ttl"` + URIs []string `json:"uris"` +}