websocket

package
v0.0.0-...-56eedac Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package websocket provides a WebSocket endpoint implementation for the RuleGo framework. It allows creating WebSocket servers that can receive and process incoming WebSocket messages, routing them to appropriate rule chains or components for further processing.

Key components in this package include: - Endpoint (alias Websocket): Implements the WebSocket server and message handling - RequestMessage: Represents an incoming WebSocket message - ResponseMessage: Represents the WebSocket message to be sent back

The WebSocket endpoint supports dynamic routing configuration, allowing users to define message patterns and their corresponding rule chain or component destinations. It also provides flexibility in handling different WebSocket message types and formats.

This package integrates with the broader RuleGo ecosystem, enabling seamless data flow from WebSocket messages to rule processing and back to WebSocket responses.

Index

Constants

View Source
const Type = types.EndpointTypePrefix + "ws"

Type 组件类型

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config = rest.Config

Config Websocket 服务配置

type Endpoint

type Endpoint = Websocket

Endpoint 别名

type RequestMessage

type RequestMessage struct {

	//路径参数
	Params httprouter.Params
	// contains filtered or unexported fields
}

RequestMessage websocket请求消息

func (*RequestMessage) Body

func (r *RequestMessage) Body() []byte

func (RequestMessage) From

func (r RequestMessage) From() string

func (*RequestMessage) GetError

func (r *RequestMessage) GetError() error

func (*RequestMessage) GetMsg

func (r *RequestMessage) GetMsg() *types.RuleMsg

func (*RequestMessage) GetParam

func (r *RequestMessage) GetParam(key string) string

func (*RequestMessage) Headers

func (r *RequestMessage) Headers() textproto.MIMEHeader

func (*RequestMessage) Request

func (r *RequestMessage) Request() *http.Request

func (*RequestMessage) SetBody

func (r *RequestMessage) SetBody(body []byte)

func (*RequestMessage) SetError

func (r *RequestMessage) SetError(err error)

func (*RequestMessage) SetMsg

func (r *RequestMessage) SetMsg(msg *types.RuleMsg)

func (*RequestMessage) SetStatusCode

func (r *RequestMessage) SetStatusCode(statusCode int)

type ResponseMessage

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

ResponseMessage websocket响应消息

func (*ResponseMessage) Body

func (r *ResponseMessage) Body() []byte

func (*ResponseMessage) From

func (r *ResponseMessage) From() string

func (*ResponseMessage) GetError

func (r *ResponseMessage) GetError() error

func (*ResponseMessage) GetMsg

func (r *ResponseMessage) GetMsg() *types.RuleMsg

func (*ResponseMessage) GetParam

func (r *ResponseMessage) GetParam(key string) string

func (*ResponseMessage) Headers

func (r *ResponseMessage) Headers() textproto.MIMEHeader

func (*ResponseMessage) SetBody

func (r *ResponseMessage) SetBody(body []byte)

func (*ResponseMessage) SetError

func (r *ResponseMessage) SetError(err error)

func (*ResponseMessage) SetMsg

func (r *ResponseMessage) SetMsg(msg *types.RuleMsg)

func (*ResponseMessage) SetStatusCode

func (r *ResponseMessage) SetStatusCode(statusCode int)

SetStatusCode 不提供设置状态码

type Websocket

type Websocket struct {
	*rest.Rest
	//配置
	Config   Config
	Upgrader websocket.Upgrader
}

Websocket 接收端端点

func (*Websocket) AddRouter

func (ws *Websocket) AddRouter(router endpoint.Router, params ...interface{}) (id string, err error)

func (*Websocket) Id

func (ws *Websocket) Id() string

func (*Websocket) Init

func (ws *Websocket) Init(ruleConfig types.Config, configuration types.Configuration) error

Init 初始化

func (*Websocket) New

func (ws *Websocket) New() types.Node

func (*Websocket) Printf

func (ws *Websocket) Printf(format string, v ...interface{})

func (*Websocket) RemoveRouter

func (ws *Websocket) RemoveRouter(routerId string, params ...interface{}) error

func (*Websocket) Start

func (ws *Websocket) Start() error

func (*Websocket) Type

func (ws *Websocket) Type() string

Type 组件类型

Jump to

Keyboard shortcuts

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