server

package
v0.0.0-...-9473012 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestInterval = time.Minute
)

Variables

This section is empty.

Functions

func AddSelfID

func AddSelfID(id string)

AddSelfID 添加一个 ID 到全局切片中

func CloseAllConnections

func CloseAllConnections()

func GetSelfIDs

func GetSelfIDs() []string

GetSelfIDs 返回当前保存的所有 ID

func IsSelfIDExists

func IsSelfIDExists(id string) bool

IsSelfIDExists 检查一个 ID 是否存在于全局切片中

func OriginalUploadBehavior

func OriginalUploadBehavior(base64Image string) (string, error)

func OriginalUploadBehaviorRecord

func OriginalUploadBehaviorRecord(base64Image string) (string, error)

将base64语音通过lotus转换成url

func SendMessageBySelfID

func SendMessageBySelfID(selfID string, message map[string]interface{}) error

发信息给client

func UploadBase64ImageHandler

func UploadBase64ImageHandler(rateLimiter *RateLimiter) http.HandlerFunc

闭包,网页后端,图床逻辑,基于gin和www静态文件的简易图床

func UploadBase64RecordHandler

func UploadBase64RecordHandler(rateLimiter *RateLimiter) http.HandlerFunc

闭包,网页后端,语音床逻辑,基于www静态文件的简易语音床

func WsHandler

func WsHandler(w http.ResponseWriter, r *http.Request, config *config.Config)

用于处理WebSocket连接

Types

type RateLimiter

type RateLimiter struct {
	Counts map[string][]time.Time
}

func NewRateLimiter

func NewRateLimiter() *RateLimiter

频率限制器

func (*RateLimiter) CheckAndUpdateRateLimit

func (rl *RateLimiter) CheckAndUpdateRateLimit(ipAddress string) bool

检查是否超过调用频率限制

type WebSocketServerClient

type WebSocketServerClient struct {
	SelfID string
	Conn   *websocket.Conn
}

func (*WebSocketServerClient) Close

func (client *WebSocketServerClient) Close() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL