Browse Source

Implemented client side sessions request.

pull/48/head
Simon Eisenmann 11 years ago committed by Simon Eisenmann
parent
commit
e6f2182e49
  1. 46
      doc/CHANNELING-API.txt
  2. 25
      src/app/spreed-webrtc-server/channeling.go
  3. 8
      src/app/spreed-webrtc-server/hub.go
  4. 13
      static/js/mediastream/api.js
  5. 4
      static/js/services/buddylist.js

46
doc/CHANNELING-API.txt

@ -389,11 +389,9 @@ Information retrieval
{ {
"Type": "Sessions", "Type": "Sessions",
"Sessions": { "Id": "Client generated request ID",
"Id": "Client generated request ID", "Token": "Request token",
"Token": "Request token", "TokenType": "Token type"
"Type": "Token type"
}
} }
Valid known token types are: "contact". Valid known token types are: "contact".
@ -403,26 +401,24 @@ Information retrieval
{ {
"Type": "Sessions", "Type": "Sessions",
"Sessions": { "Id": "ID as from request",
"Id": "ID as from request", "Token": "Token as in request",
"Token": "Token as in request", "TokenType": "Type as in request",
"Type": "Type as in request", "Users": [
"Users": [ {
{ "Type": "Online",
"Type": "Online", "Id": "1",
"Id": "1", "Ua": "Firefox 27",
"Ua": "Firefox 27", "Status": {...}
"Status": {...} },
}, {
{ "Type": "Online",
"Type": "Online", "Id": "3",
"Id": "3", "Userid": "u3",
"Userid": "u3", "Ua": "Chrome 28",
"Ua": "Chrome 28", "Status": {...}
"Status": {...} }, ...
}, ... ]
]
}
} }

25
src/app/spreed-webrtc-server/channeling.go

@ -65,13 +65,13 @@ type DataTurn struct {
} }
type DataSession struct { type DataSession struct {
Type string
Id string Id string
Userid string `json:"Userid,omitempty"` Type string `json:",omitempty"`
Ua string `json:"Ua,omitempty"` Userid string `json:",omitempty"`
Token string `json:"Token,omitempty"` Ua string `json:",omitempty"`
Version string `json:"Version,omitempty"` Token string `json:",omitempty"`
Rev uint64 `json:"Rev,omitempty"` Version string `json:",omitempty"`
Rev uint64 `json:",omitempty"`
Status interface{} Status interface{}
} }
@ -157,12 +157,13 @@ type DataOutgoing struct {
} }
type DataSessions struct { type DataSessions struct {
Type string Type string
Users []*DataSession Users []*DataSession
Id string `json:",omitempty"` Id string `json:",omitempty"`
Token string `json:",omitempty"` Token string `json:",omitempty"`
Index uint64 `json:",omitempty"` TokenType string `json:",omitempty"`
Batch uint64 `json:",omitempty"` Index uint64 `json:",omitempty"`
Batch uint64 `json:",omitempty"`
} }
type DataConference struct { type DataConference struct {

8
src/app/spreed-webrtc-server/hub.go

@ -424,12 +424,12 @@ func (h *Hub) sessionsHandler(c *Connection, sessions *DataSessions) {
reply := false reply := false
switch sessions.Type { switch sessions.TokenType {
case "contact": case "contact":
contact := &Contact{} contact := &Contact{}
err := h.contacts.Decode("contactConfirmed", sessions.Token, contact) err := h.contacts.Decode("contactRequest", sessions.Token, contact)
if err != nil { if err != nil {
log.Println("Failed to decode incoming contact token", err) log.Println("Failed to decode incoming contact token", err, sessions.Token)
return return
} }
// Use the userid which is not ours from the contact data. // Use the userid which is not ours from the contact data.
@ -454,7 +454,7 @@ func (h *Hub) sessionsHandler(c *Connection, sessions *DataSessions) {
sessions.Users = user.SessionsData() sessions.Users = user.SessionsData()
reply = true reply = true
default: default:
log.Println("Unkown incoming sessions request type", sessions.Type) log.Println("Unkown incoming sessions request type", sessions.TokenType)
} }
if reply { if reply {

13
static/js/mediastream/api.js

@ -321,6 +321,19 @@ define(['jquery', 'underscore'], function($, _) {
return this.send("Alive", data); return this.send("Alive", data);
}; };
Api.prototype.sendSessions = function(token, type) {
var data = {
Type: "Sessions",
Id: "some-random-whatever",
Token: token,
TokenType: type
}
return this.send("Sessions", data);
};
return Api; return Api;
}); });

4
static/js/services/buddylist.js

@ -664,6 +664,10 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
if (!sessionData) { if (!sessionData) {
// TODO(longsleep): Find session with help of contact. // TODO(longsleep): Find session with help of contact.
console.log("No sessions for this buddy.", session, contact); console.log("No sessions for this buddy.", session, contact);
if (contact && contact.Token) {
mediaStream.api.sendSessions(contact.Token, "contact");
}
return;
} else { } else {
id = sessionData.Id; id = sessionData.Id;
} }

Loading…
Cancel
Save