mirror of
https://github.com/pion/webrtc.git
synced 2025-10-16 12:10:44 +08:00
Upgrade golangci-lint, more linters
Introduces new linters, upgrade golangci-lint to version (v1.63.4)
This commit is contained in:
@@ -15,7 +15,8 @@ import (
|
||||
)
|
||||
|
||||
// websocketServer is called for every new inbound WebSocket
|
||||
func websocketServer(ws *websocket.Conn) { // nolint:gocognit
|
||||
// nolint: gocognit, cyclop
|
||||
func websocketServer(wsConn *websocket.Conn) {
|
||||
// Create a new RTCPeerConnection
|
||||
peerConnection, err := webrtc.NewPeerConnection(webrtc.Configuration{})
|
||||
if err != nil {
|
||||
@@ -26,17 +27,17 @@ func websocketServer(ws *websocket.Conn) { // nolint:gocognit
|
||||
// ice trickle is implemented. Everytime we have a new candidate available we send
|
||||
// it as soon as it is ready. We don't wait to emit a Offer/Answer until they are
|
||||
// all available
|
||||
peerConnection.OnICECandidate(func(c *webrtc.ICECandidate) {
|
||||
if c == nil {
|
||||
peerConnection.OnICECandidate(func(candidate *webrtc.ICECandidate) {
|
||||
if candidate == nil {
|
||||
return
|
||||
}
|
||||
|
||||
outbound, marshalErr := json.Marshal(c.ToJSON())
|
||||
outbound, marshalErr := json.Marshal(candidate.ToJSON())
|
||||
if marshalErr != nil {
|
||||
panic(marshalErr)
|
||||
}
|
||||
|
||||
if _, err = ws.Write(outbound); err != nil {
|
||||
if _, err = wsConn.Write(outbound); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
@@ -61,7 +62,7 @@ func websocketServer(ws *websocket.Conn) { // nolint:gocognit
|
||||
buf := make([]byte, 1500)
|
||||
for {
|
||||
// Read each inbound WebSocket Message
|
||||
n, err := ws.Read(buf)
|
||||
n, err := wsConn.Read(buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -94,7 +95,7 @@ func websocketServer(ws *websocket.Conn) { // nolint:gocognit
|
||||
panic(marshalErr)
|
||||
}
|
||||
|
||||
if _, err = ws.Write(outbound); err != nil {
|
||||
if _, err = wsConn.Write(outbound); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// Attempt to unmarshal as a ICECandidateInit. If the candidate field is empty
|
||||
|
Reference in New Issue
Block a user