blob: de50fa06b1d78e3597205e750e36a3ff0c642ea5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package wsapi
import (
"github.com/mattermost/mattermost-server/model"
)
func (api *API) InitWebrtc() {
api.Router.Handle("webrtc", api.ApiWebSocketHandler(api.webrtcMessage))
}
func (api *API) webrtcMessage(req *model.WebSocketRequest) (map[string]interface{}, *model.AppError) {
var ok bool
var toUserId string
if toUserId, ok = req.Data["to_user_id"].(string); !ok || len(toUserId) != 26 {
return nil, NewInvalidWebSocketParamError(req.Action, "to_user_id")
}
event := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_WEBRTC, "", "", toUserId, nil)
event.Data = req.Data
api.App.Publish(event)
return nil, nil
}
|