mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-17 21:16:33 +02:00
Pass along dialout status through transient data.
This commit is contained in:
parent
e1273a3c52
commit
3a7b4c48dc
14
api_async.go
14
api_async.go
|
@ -21,7 +21,11 @@
|
||||||
*/
|
*/
|
||||||
package signaling
|
package signaling
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type AsyncMessage struct {
|
type AsyncMessage struct {
|
||||||
SendTime time.Time `json:"sendtime"`
|
SendTime time.Time `json:"sendtime"`
|
||||||
|
@ -41,6 +45,14 @@ type AsyncMessage struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *AsyncMessage) String() string {
|
||||||
|
data, err := json.Marshal(m)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Sprintf("Could not serialize %#v: %s", m, err)
|
||||||
|
}
|
||||||
|
return string(data)
|
||||||
|
}
|
||||||
|
|
||||||
type AsyncRoomMessage struct {
|
type AsyncRoomMessage struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -107,6 +108,8 @@ type BackendServerRoomRequest struct {
|
||||||
|
|
||||||
Dialout *BackendRoomDialoutRequest `json:"dialout,omitempty"`
|
Dialout *BackendRoomDialoutRequest `json:"dialout,omitempty"`
|
||||||
|
|
||||||
|
Transient *BackendRoomTransientRequest `json:"transient,omitempty"`
|
||||||
|
|
||||||
// Internal properties
|
// Internal properties
|
||||||
ReceivedTime int64 `json:"received,omitempty"`
|
ReceivedTime int64 `json:"received,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -200,6 +203,20 @@ func (r *BackendRoomDialoutRequest) ValidateNumber() *Error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TransientAction string
|
||||||
|
|
||||||
|
const (
|
||||||
|
TransientActionSet TransientAction = "set"
|
||||||
|
TransientActionDelete TransientAction = "delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BackendRoomTransientRequest struct {
|
||||||
|
Action TransientAction `json:"action"`
|
||||||
|
Key string `json:"key"`
|
||||||
|
Value interface{} `json:"value,omitempty"`
|
||||||
|
TTL time.Duration `json:"ttl,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type BackendServerRoomResponse struct {
|
type BackendServerRoomResponse struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
|
||||||
|
|
39
hub.go
39
hub.go
|
@ -97,6 +97,9 @@ var (
|
||||||
|
|
||||||
// Delay after which a screen publisher should be cleaned up.
|
// Delay after which a screen publisher should be cleaned up.
|
||||||
cleanupScreenPublisherDelay = time.Second
|
cleanupScreenPublisherDelay = time.Second
|
||||||
|
|
||||||
|
// Delay after which a "cleared" / "rejected" dialout status should be removed.
|
||||||
|
removeCallStatusTTL = 5 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -1942,14 +1945,34 @@ func (h *Hub) processInternalMsg(client *Client, message *ClientMessage) {
|
||||||
case "dialout":
|
case "dialout":
|
||||||
roomId := msg.Dialout.RoomId
|
roomId := msg.Dialout.RoomId
|
||||||
msg.Dialout.RoomId = "" // Don't send room id to recipients.
|
msg.Dialout.RoomId = "" // Don't send room id to recipients.
|
||||||
if err := h.events.PublishRoomMessage(roomId, session.Backend(), &AsyncMessage{
|
if msg.Dialout.Type == "status" {
|
||||||
Type: "message",
|
asyncMessage := &AsyncMessage{
|
||||||
Message: &ServerMessage{
|
Type: "room",
|
||||||
Type: "dialout",
|
Room: &BackendServerRoomRequest{
|
||||||
Dialout: msg.Dialout,
|
Type: "transient",
|
||||||
},
|
Transient: &BackendRoomTransientRequest{
|
||||||
}); err != nil {
|
Action: TransientActionSet,
|
||||||
log.Printf("Error publishing dialout message %+v to room %s", msg.Dialout, roomId)
|
Key: "callstatus_" + msg.Dialout.Status.CallId,
|
||||||
|
Value: msg.Dialout.Status,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
if msg.Dialout.Status.Status == DialoutStatusCleared || msg.Dialout.Status.Status == DialoutStatusRejected {
|
||||||
|
asyncMessage.Room.Transient.TTL = removeCallStatusTTL
|
||||||
|
}
|
||||||
|
if err := h.events.PublishBackendRoomMessage(roomId, session.Backend(), asyncMessage); err != nil {
|
||||||
|
log.Printf("Error publishing dialout message %+v to room %s", msg.Dialout, roomId)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := h.events.PublishRoomMessage(roomId, session.Backend(), &AsyncMessage{
|
||||||
|
Type: "message",
|
||||||
|
Message: &ServerMessage{
|
||||||
|
Type: "dialout",
|
||||||
|
Dialout: msg.Dialout,
|
||||||
|
},
|
||||||
|
}); err != nil {
|
||||||
|
log.Printf("Error publishing dialout message %+v to room %s", msg.Dialout, roomId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
log.Printf("Ignore unsupported internal message %+v from %s", msg, session.PublicId())
|
log.Printf("Ignore unsupported internal message %+v from %s", msg, session.PublicId())
|
||||||
|
|
9
room.go
9
room.go
|
@ -244,6 +244,15 @@ func (r *Room) processBackendRoomRequestRoom(message *BackendServerRoomRequest)
|
||||||
r.publishRoomMessage(message.Message)
|
r.publishRoomMessage(message.Message)
|
||||||
case "switchto":
|
case "switchto":
|
||||||
r.publishSwitchTo(message.SwitchTo)
|
r.publishSwitchTo(message.SwitchTo)
|
||||||
|
case "transient":
|
||||||
|
switch message.Transient.Action {
|
||||||
|
case TransientActionSet:
|
||||||
|
r.SetTransientDataTTL(message.Transient.Key, message.Transient.Value, message.Transient.TTL)
|
||||||
|
case TransientActionDelete:
|
||||||
|
r.RemoveTransientData(message.Transient.Key)
|
||||||
|
default:
|
||||||
|
log.Printf("Unsupported transient action in room %s: %+v", r.Id(), message.Transient)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
log.Printf("Unsupported backend room request with type %s in %s: %+v", message.Type, r.Id(), message)
|
log.Printf("Unsupported backend room request with type %s in %s: %+v", message.Type, r.Id(), message)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue