websocketserver

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Conn     *websocket.Conn
	Messages chan string // 为每个客户端设置独立的消息通道
}

type WebSocketServer

type WebSocketServer struct {
	// contains filtered or unexported fields
}

WebSocketServer 处理结构体

func NewWebSocketServer

func NewWebSocketServer(token string) *WebSocketServer

NewWebSocketServer 创建一个新的 WebSocket 服务器实例

func (*WebSocketServer) HandleClient

func (wsServer *WebSocketServer) HandleClient(conn *websocket.Conn, r *http.Request)

HandleClient 处理 WebSocket 客户端连接

func (*WebSocketServer) SendMessageToClient

func (wsServer *WebSocketServer) SendMessageToClient(origin string, msg string) (chan string, error)

func (*WebSocketServer) ServeHTTP

func (wsServer *WebSocketServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP WebSocket 路由处理函数

func (*WebSocketServer) Start

func (ws *WebSocketServer) Start(addr string)

Jump to

Keyboard shortcuts

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