github.com/spline-fu/mattermost-server@v4.10.10+incompatible/wsapi/webrtc.go (about)

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