relay

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: BSD-4-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRelayServer

func NewRelayServer(config *config.RelayConfig, wsServer *WsServer) *relayServer

Types

type ClientUnregisterEvent

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

type MessageType

type MessageType string
const (
	Pub MessageType = "pub"
	Sub MessageType = "sub"
	Ack MessageType = "ack"

	Ping MessageType = "ping"
	Pong MessageType = "pong"
)

type PhaseType

type PhaseType string
const (
	SessionRequest   PhaseType = "sessionRequest"
	SessionReceived  PhaseType = "sessionReceived"
	SessionExpired   PhaseType = "sessionExpired"
	SessionStart     PhaseType = "sessionStart"
	SessionSuspended PhaseType = "sessionSuspended"
	SessionResumed   PhaseType = "sessionResumed"
)

type RoleType

type RoleType string
const (
	Dapp   RoleType = "dapp"
	Wallet RoleType = "wallet"
	Relay  RoleType = "relay"
)

type SocketMessage

type SocketMessage struct {
	Topic   string      `json:"topic"`
	Type    MessageType `json:"type"` // pub, sub, ack
	Payload string      `json:"payload"`
	Role    string      `json:"role"`
	Phase   string      `json:"phase"`
	Silent  bool        `json:"silent"`
	// contains filtered or unexported fields
}

websocket message

func (SocketMessage) MarshalBinary

func (sm SocketMessage) MarshalBinary() ([]byte, error)

type TopicClientSet

type TopicClientSet struct {
	*sync.RWMutex
	Data map[string]map[*client]struct{}
}

TopicClientSet stores topic -> clients relationship

func NewTopicClientSet

func NewTopicClientSet() *TopicClientSet

func (*TopicClientSet) Clear

func (ts *TopicClientSet) Clear(topic string)

func (*TopicClientSet) Get

func (ts *TopicClientSet) Get(topic string) map[*client]struct{}

func (*TopicClientSet) GetTopicsByClient

func (ts *TopicClientSet) GetTopicsByClient(c *client, clear bool) []string

GetTopicsByClient returns the topics associated with the specified client, meanwhile, remove the client from these topics if `clear` is true returns the topics the client has associated with

func (*TopicClientSet) Len

func (ts *TopicClientSet) Len(topic string) int

func (*TopicClientSet) Set

func (ts *TopicClientSet) Set(topic string, c *client)

func (*TopicClientSet) Unset

func (ts *TopicClientSet) Unset(topic string, c *client)

type TopicSet

type TopicSet struct {
	*sync.RWMutex
	Data map[string]struct{}
}

func NewTopicSet

func NewTopicSet() *TopicSet

func (TopicSet) Get added in v1.0.2

func (tm TopicSet) Get() map[string]struct{}

func (TopicSet) MarshalLogArray

func (tm TopicSet) MarshalLogArray(encoder zapcore.ArrayEncoder) error

func (TopicSet) Set added in v1.0.1

func (tm TopicSet) Set(topic string)

type WsMessageHandler

type WsMessageHandler func(*WsServer, SocketMessage)

type WsServer

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

func NewWSServer

func NewWSServer(config *config.Config) *WsServer

func (*WsServer) GetDappPublisher

func (ws *WsServer) GetDappPublisher(topic string) []*client

GetDappPulisher gets the topic publisher and check whether its role is "dapp" the return value indicates whether the notification target has been found

func (*WsServer) GetSubscriber

func (ws *WsServer) GetSubscriber(topic string) []*client

func (*WsServer) NewClientConn

func (ws *WsServer) NewClientConn(w http.ResponseWriter, r *http.Request)

func (*WsServer) Run

func (ws *WsServer) Run()

func (*WsServer) Shutdown

func (ws *WsServer) Shutdown()

Jump to

Keyboard shortcuts

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