2024-02-03 11:34:26 +01:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
package websocket
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.gitea.io/gitea/modules/context"
|
2024-02-03 22:13:32 +01:00
|
|
|
|
2024-02-03 11:34:26 +01:00
|
|
|
"github.com/olahol/melody"
|
|
|
|
)
|
|
|
|
|
|
|
|
func HandleConnect(s *melody.Session) {
|
|
|
|
ctx := context.GetWebContext(s.Request)
|
|
|
|
|
|
|
|
if !ctx.IsSigned {
|
|
|
|
// Return unauthorized status event
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
uid := ctx.Doer.ID
|
2024-02-03 14:11:05 +01:00
|
|
|
sessionData := &sessionData{
|
2024-02-03 16:41:20 +01:00
|
|
|
uid: uid,
|
2024-02-03 11:34:26 +01:00
|
|
|
}
|
|
|
|
s.Set("data", sessionData)
|
2024-02-03 20:30:04 +01:00
|
|
|
|
|
|
|
// TODO: handle logouts
|
2024-02-03 11:34:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func HandleMessage(s *melody.Session, msg []byte) {
|
|
|
|
// TODO: Handle incoming messages
|
|
|
|
}
|
|
|
|
|
|
|
|
func HandleDisconnect(s *melody.Session) {
|
2024-02-03 16:41:20 +01:00
|
|
|
// TODO: Handle disconnect
|
2024-02-03 11:34:26 +01:00
|
|
|
}
|