Documentation ¶
Index ¶
- func NewFiberWebSocketHandler(app *fiber.App, system *vivid.ActorSystem, configurator ...Configurator) fiber.Handler
- type Actor
- type Configuration
- type Configurator
- type FunctionalConfigurator
- type GNETEventHandler
- func (g *GNETEventHandler) OnBoot(eng gnet.Engine) (action gnet.Action)
- func (g *GNETEventHandler) OnClose(c gnet.Conn, err error) (action gnet.Action)
- func (g *GNETEventHandler) OnOpen(c gnet.Conn) (out []byte, action gnet.Action)
- func (g *GNETEventHandler) OnShutdown(eng gnet.Engine)
- func (g *GNETEventHandler) OnTick() (delay time.Duration, action gnet.Action)
- func (g *GNETEventHandler) OnTraffic(c gnet.Conn) (action gnet.Action)
- type Packet
- type Stream
- type Writer
- type WriterCreatedHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFiberWebSocketHandler ¶
func NewFiberWebSocketHandler(app *fiber.App, system *vivid.ActorSystem, configurator ...Configurator) fiber.Handler
NewFiberWebSocketHandler 创建一个 fiber.Handler,它将会对请求进行 WebSocket 升级,并采用 Actor 对其进行维护。
- 这看来似乎是必须的,如果你要对消息进行处理,那么请在 Configurator 内指定 Configuration.WithPerformance 可选项,这可以让你得到 Stream 的 vivid.ActorContext,并对其进行控制。
在 Stream 的 vivid.ActorContext 中会传入三个特殊消息,你可以选择使用它们:
- stream.Writer:在 Stream Actor 启动后,将会收到一个写入器,这个写入器接收 *stream.Packet 类型的消息,它将会将消息写入到连接中。
- *websocket.Conn:这是 WebSocket 的特殊消息,你可以获取它来进行额外的操作。
- *stream.Packet:当收到该消息,也就意味着存在需要处理的数据包。
Types ¶
type Actor ¶
type Actor struct {
// contains filtered or unexported fields
}
func NewStream ¶
func NewStream(conn Stream, configurator ...Configurator) *Actor
func (*Actor) OnReceive ¶
func (c *Actor) OnReceive(ctx vivid.ActorContext)
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
Configuration 流配置
func (*Configuration) WithPerformance ¶
func (c *Configuration) WithPerformance(performance behavior.Performance[vivid.ActorContext])
WithPerformance 设置流的行为表现,你可以像控制 Actor 一样控制它
type Configurator ¶
type Configurator interface {
Configure(c *Configuration)
}
type FunctionalConfigurator ¶
type FunctionalConfigurator func(c *Configuration)
func (FunctionalConfigurator) Configure ¶
func (f FunctionalConfigurator) Configure(c *Configuration)
type GNETEventHandler ¶
type GNETEventHandler struct {
// contains filtered or unexported fields
}
func NewGNETEventHandler ¶
func NewGNETEventHandler(system *vivid.ActorSystem, configurator ...Configurator) *GNETEventHandler
func (*GNETEventHandler) OnBoot ¶
func (g *GNETEventHandler) OnBoot(eng gnet.Engine) (action gnet.Action)
func (*GNETEventHandler) OnClose ¶
func (g *GNETEventHandler) OnClose(c gnet.Conn, err error) (action gnet.Action)
func (*GNETEventHandler) OnOpen ¶
func (g *GNETEventHandler) OnOpen(c gnet.Conn) (out []byte, action gnet.Action)
func (*GNETEventHandler) OnShutdown ¶
func (g *GNETEventHandler) OnShutdown(eng gnet.Engine)
func (*GNETEventHandler) OnTick ¶
func (g *GNETEventHandler) OnTick() (delay time.Duration, action gnet.Action)
func (*GNETEventHandler) OnTraffic ¶
func (g *GNETEventHandler) OnTraffic(c gnet.Conn) (action gnet.Action)
type Packet ¶
type Packet struct {
// contains filtered or unexported fields
}
func NewPacketC ¶
func NewPacketD ¶
func NewPacketDC ¶
func NewPacketS ¶
func NewPacketSC ¶
func (*Packet) Derivation ¶
Derivation 继承数据包上下文派生一个新的数据包
func (*Packet) SetContext ¶
type WriterCreatedHook ¶
Click to show internal directories.
Click to hide internal directories.