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

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

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

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

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

13
static/js/mediastream/api.js

@ -321,6 +321,19 @@ define(['jquery', 'underscore'], function($, _) { @@ -321,6 +321,19 @@ define(['jquery', 'underscore'], function($, _) {
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;
});

4
static/js/services/buddylist.js

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

Loading…
Cancel
Save