MCPcopy Index your code
hub / github.com/koding/kite / ParseWebRTCSignalMessage

Function ParseWebRTCSignalMessage

protocol/webrtc.go:68–84  ·  view source on GitHub ↗

ParseWebRTCSignalMessage parses the web rtc command/message

(msg string)

Source from the content-addressed store, hash-verified

66
67// ParseWebRTCSignalMessage parses the web rtc command/message
68func ParseWebRTCSignalMessage(msg string) (*WebRTCSignalMessage, error) {
69 // All messages are text (utf-8 encoded at present)
70 if !utf8.Valid([]byte(msg)) {
71 return nil, errInvalidChar
72 }
73
74 w := &WebRTCSignalMessage{}
75 if err := json.Unmarshal([]byte(msg), w); err != nil {
76 return nil, err
77 }
78
79 if err := validateOperation(w.Type); err != nil {
80 return nil, err
81 }
82
83 return w, nil
84}
85
86func validateOperation(op string) error {
87 switch strings.ToUpper(op) {

Callers 1

TestParseWebRTCMessageFunction · 0.85

Calls 2

validateOperationFunction · 0.85
UnmarshalMethod · 0.80

Tested by 1

TestParseWebRTCMessageFunction · 0.68