From 69db76290dbbfe4f476d2a4d1357b3eaa249ac75 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Mon, 20 Apr 2015 15:07:41 +0200 Subject: [PATCH] Added server side ApiVersion returned with self to distinguish client and server API version support. --- doc/CHANNELING-API.txt | 36 +++++++++++-------- src/app/spreed-webrtc-server/channelling.go | 19 +++++----- .../spreed-webrtc-server/channelling_api.go | 20 ++++++----- static/js/app.js | 4 +-- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/doc/CHANNELING-API.txt b/doc/CHANNELING-API.txt index c3a34cb0..1d4e03be 100644 --- a/doc/CHANNELING-API.txt +++ b/doc/CHANNELING-API.txt @@ -117,6 +117,7 @@ Special purpose documents for channling "Suserid": "", "Token": "some-very-long-string", "Version": "server-version-number", + "ApiVersion": 1.4, "Turn": { "username": "turn-username", "password": "turn-password", @@ -136,21 +137,26 @@ Special purpose documents for channling Keys: - Type : Self (string) - Id : Public Session id for this connection (string). - Sid : Secure (non public) id for this session (string). - Userid : User id if this session belongs to an authenticated user. Else empty. - Suserid : Secure (non public) user id if session has an user id. Else empty. - Token : Security token (string), to restablish connection with the same - session. Pass the value as URL query parameter t, to the websocket URL. - Version : Server version number. Use this to detect server upgrades. - Turn : Mapping (interface{}) to contain TURN server details, like - urls, password and username. See - http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00 - and TURN REST API section in - https://code.google.com/p/rfc5766-turn-server/wiki/turnserver - for details. - Stun : Array with STUN server URLs. + Type : Self (string) + Id : Public Session id for this connection (string). + Sid : Secure (non public) id for this session (string). + Userid : User id if this session belongs to an authenticated user. + Else empty. + Suserid : Secure (non public) user id if session has an user id. + Else empty. + Token : Security token (string), to restablish connection with the + same session. Pass the value as URL query parameter t, to + the websocket URL. + Version : Server version number. Use this to detect server upgrades. + ApiVersion : Server channeling API base version. Use this version to select + client side compatibility with the connected server. + Turn : Mapping (interface{}) to contain TURN server details, like + urls, password and username. See + http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00 + and TURN REST API section in + https://code.google.com/p/rfc5766-turn-server/wiki/turnserver + for details. + Stun : Array with STUN server URLs. You can also send an empty Self document to the server to make the server transmit a fresh Self document (eg. to refresh when ttl was reached). Please diff --git a/src/app/spreed-webrtc-server/channelling.go b/src/app/spreed-webrtc-server/channelling.go index c05dcf8e..2fcd68c5 100644 --- a/src/app/spreed-webrtc-server/channelling.go +++ b/src/app/spreed-webrtc-server/channelling.go @@ -79,15 +79,16 @@ type DataAnswer struct { } type DataSelf struct { - Type string - Id string - Sid string - Userid string - Suserid string - Token string - Version string - Turn *DataTurn - Stun []string + Type string + Id string + Sid string + Userid string + Suserid string + Token string + Version string // Server version. + ApiVersion float64 // Server channelling API version. + Turn *DataTurn + Stun []string } type DataTurn struct { diff --git a/src/app/spreed-webrtc-server/channelling_api.go b/src/app/spreed-webrtc-server/channelling_api.go index 958e9a9b..afd5b581 100644 --- a/src/app/spreed-webrtc-server/channelling_api.go +++ b/src/app/spreed-webrtc-server/channelling_api.go @@ -28,6 +28,7 @@ import ( const ( maxConferenceSize = 100 + apiVersion = 1.4 // Keep this in sync with CHANNELING-API docs.Hand ) type ChannellingAPI interface { @@ -171,15 +172,16 @@ func (api *channellingAPI) HandleSelf(session *Session) (*DataSelf, error) { log.Println("Created new session token", len(token), token) self := &DataSelf{ - Type: "Self", - Id: session.Id, - Sid: session.Sid, - Userid: session.Userid(), - Suserid: api.EncodeSessionUserID(session), - Token: token, - Version: api.Version, - Turn: api.CreateTurnData(session), - Stun: api.StunURIs, + Type: "Self", + Id: session.Id, + Sid: session.Sid, + Userid: session.Userid(), + Suserid: api.EncodeSessionUserID(session), + Token: token, + Version: api.Version, + ApiVersion: apiVersion, + Turn: api.CreateTurnData(session), + Stun: api.StunURIs, } return self, nil diff --git a/static/js/app.js b/static/js/app.js index 3180afc7..d63c58a0 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -208,9 +208,9 @@ define([ }; - // Our API version as float. This value is incremented on + // Our client side API version as float. This value is incremented on // breaking changes to plugins can check on it. - var apiversion = 1.4; + var apiversion = 1.1; var initialize = function(app, launcher) {