Documentation ¶
Overview ¶
Package chirp describes peer-to-peer communication protocol.
Index ¶
- Constants
- Variables
- func DumpConnectionsState()
- func DumpNodeState()
- func GetOrCreateRealm(appID string, credential string) (realm *node)
- func NewSigChannelJoined(chName string) *psig.Signalling
- func NewSigPeerOffline(chid string, p *Peer) *psig.Signalling
- func NewSigPeerOnline(chid string, p *Peer) *psig.Signalling
- type Channel
- type Connection
- type Peer
- type WebSocketConnection
- type WebTransportConnection
Constants ¶
const ( // Endpoint is the base path of service Endpoint string = "/v1" )
Variables ¶
var AuthUserAndGetYoMoCredential func(publicKey string) (appID, credential string, ok bool)
AuthUserAndGetYoMoCredential is used to authenticate user by `publickey` and get credential used to connect to YoMo
Functions ¶
func DumpConnectionsState ¶
func DumpConnectionsState()
DumpConnectionsState prints the user and room information to stdout.
func DumpNodeState ¶
func DumpNodeState()
DumpNodeState prints the user and room information to stdout.
func GetOrCreateRealm ¶
GetOrCreateRealm get or create realm by appID, if realm is created, it will connect to yomo zipper with credential.
func NewSigChannelJoined ¶
func NewSigChannelJoined(chName string) *psig.Signalling
NewSigChannelJoined create OpChannelJoin message.
func NewSigPeerOffline ¶
func NewSigPeerOffline(chid string, p *Peer) *psig.Signalling
NewSigPeerOffline create OpPeerOffline message.
func NewSigPeerOnline ¶
func NewSigPeerOnline(chid string, p *Peer) *psig.Signalling
NewSigPeerOnline create OpPeerOnline message.
Types ¶
type Channel ¶
type Channel struct { UniqID string // uniq id // contains filtered or unexported fields }
Channel describes a message channel.
func (*Channel) Broadcast ¶
func (c *Channel) Broadcast(sig *psig.Signalling)
Broadcast message to all peers in this channel by yomo, yomo create a distributed cloud network, peers from different location will connect to different nodes in this network, so the message will be broadcast to all nodes.
func (*Channel) Dispatch ¶
func (c *Channel) Dispatch(sig *psig.Signalling)
Dispatch messages to all peers in this channel of current node.
func (*Channel) RemovePeer ¶
RemovePeer remove peer from this channel.
type Connection ¶
type Connection interface { // RemoteAddr returns the client network address. RemoteAddr() string // Write the data to the connection Write(msg []byte) error }
Connection is connection either WebSocket or WebTransport
func NewWebSocketConnection ¶
func NewWebSocketConnection(conn net.Conn) Connection
NewWebSocketConnection creates a new WebSocketConnection
func NewWebTransportConnection ¶
func NewWebTransportConnection(conn quic.Connection) Connection
NewWebTransportConnection creates a new WebTransportConnection
type Peer ¶
type Peer struct { // Sid describes the unique id of this peer on this node, only used for backend. Sid string // Cid describes the unique id of this peer on who geo-distributed network, set by developer. Cid string // Channel describes the channel which this peer joined. Channels map[string]*Channel // contains filtered or unexported fields }
Peer describes user on this node.
func (*Peer) BroadcastToChannel ¶
func (p *Peer) BroadcastToChannel(sig *psig.Signalling)
BroadcastToChannel will broadcast message to channel.
func (*Peer) Disconnect ¶
func (p *Peer) Disconnect()
Disconnect clears resources of this peer when leave.
func (*Peer) HandleSignal ¶
HandleSignal handle message sent from connection.
func (*Peer) NotifyBack ¶
func (p *Peer) NotifyBack(sig *psig.Signalling)
NotifyBack to peer with message.
type WebSocketConnection ¶
type WebSocketConnection struct {
// contains filtered or unexported fields
}
WebSocketConnection is a WebSocket connection
func (*WebSocketConnection) RemoteAddr ¶
func (c *WebSocketConnection) RemoteAddr() string
RemoteAddr returns the client network address.
func (*WebSocketConnection) Write ¶
func (c *WebSocketConnection) Write(msg []byte) error
Write the data to the connection
type WebTransportConnection ¶
type WebTransportConnection struct {
// contains filtered or unexported fields
}
WebTransportConnection is a WebTransport connection
func (*WebTransportConnection) RemoteAddr ¶
func (c *WebTransportConnection) RemoteAddr() string
RemoteAddr returns the client network address.
func (*WebTransportConnection) Write ¶
func (c *WebTransportConnection) Write(msg []byte) error
Write the data to the connection