signaling

package
v0.0.0-...-7b89762 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultClientID = "MASTER"
)

DefaultClientID value when it not exist

View Source
const TextMessage int = 1

For using webosocket text msg

Variables

This section is empty.

Functions

func RandSeq

func RandSeq(n int) string

RandSeq Util to generate random string with n chars

func WithDateProvider

func WithDateProvider(dateProvider signer.DateProvier) func(*Client)

Use own Date Provider implementation

func WithSigner

func WithSigner(signer signer.APII) func(*Client)

Use own v4 AWS signer implementation

func WithWebsocketClient

func WithWebsocketClient(websocket WebSocketClientI) func(*Client)

Use own websocket client implementation

Types

type Client

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

Signaling client

func New

func New(config *Config, options ...func(*Client)) (*Client, error)

New signaling client

func (*Client) Close

func (sc *Client) Close()

Close signaling client

func (*Client) OnClose

func (sc *Client) OnClose(f func())

On Close Event Function

func (*Client) OnError

func (sc *Client) OnError(f func(err error))

OnError Event Function

func (*Client) OnIceCandidate

func (sc *Client) OnIceCandidate(f func(iceCandidate *string, clientID *string))

On ICE Candidate Event Function

func (*Client) OnOpen

func (sc *Client) OnOpen(f func())

On Open Event Function

func (*Client) OnSdpAnswer

func (sc *Client) OnSdpAnswer(f func(answer *string, clientID *string))

On Sdp Answer Event Function

func (*Client) OnSdpOffer

func (sc *Client) OnSdpOffer(f func(offer *string, remoteClientID *string))

On Sdp Offer Event Function

func (*Client) Open

func (sc *Client) Open() error

Open Signaling Client

func (*Client) SendIceCandidate

func (sc *Client) SendIceCandidate(iceCandidateMsg string, recipientClientID *string)

Sender signaling Ice Candidate Messages

func (*Client) SendSdpAnswer

func (sc *Client) SendSdpAnswer(sdpAnswerMsg string, recipientClientID *string)

Sender signaling Sdp Answer Messages

func (*Client) SendSdpOffer

func (sc *Client) SendSdpOffer(sdpOfferMsg string, recipientClientID *string)

Sender signalingSdp Offer Messages

type Config

type Config struct {
	ChannelARN        *string            // ARN AWS Signaling Channel
	ChannelEndpoint   *string            // WSS URL AWS signaling
	Region            *string            // AWS Region
	Role              Role               // Master or viewer actor
	ClientID          *string            // Id Client for AWS signaling protocol
	SystemClockOffset int                // An offset value in milliseconds to apply to all signing times
	CredentialsValue  *credentials.Value // AWS Credentials
}

Signaling configure

type MessageType

type MessageType string

Signaling Message Type

type ReadyStateType

type ReadyStateType string

Signaling connection State Type

type Role

type Role string

Role Type of signaling connection actor

const (
	Master Role = "MASTER"
	Viewer Role = "VIEWER"
)

Signaling connection types

type WebSocketClient

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

WebSocket Gorilla Client implementation

func (*WebSocketClient) Close

func (ws *WebSocketClient) Close()

Close Function do websocket close gratefully

func (*WebSocketClient) Dial

func (ws *WebSocketClient) Dial() error

Open connection to websocket

func (*WebSocketClient) OnClose

func (ws *WebSocketClient) OnClose(f func())

On Close Event Function

func (*WebSocketClient) OnError

func (ws *WebSocketClient) OnError(f func(err error))

OnError Event Function

func (*WebSocketClient) OnMessage

func (ws *WebSocketClient) OnMessage(dial chan string, f func(messageType int, data []byte))

On OnMessage Event Function

func (*WebSocketClient) OnOpen

func (ws *WebSocketClient) OnOpen(f func())

On Open Event Function

func (*WebSocketClient) Send

func (ws *WebSocketClient) Send(msgType int, data []byte) error

Function to send data to websocket

func (*WebSocketClient) SetURL

func (ws *WebSocketClient) SetURL(url string) error

Set url of Websocket

type WebSocketClientI

type WebSocketClientI interface {
	OnClose(func())
	OnOpen(func())
	OnError(func(err error))
	Dial() error
	Close()
	OnMessage(chan string, func(messageType int, data []byte))
	Send(int, []byte) error
	SetURL(string) error
}

WebSocket API provides an interface to enable mock

type WebSocketSignalingMessageReceive

type WebSocketSignalingMessageReceive struct {
	MessageType    MessageType `json:"messageType,omitempty"`
	MessagePayload string      `json:"messagePayload,omitempty"`
	SenderClientID string      `json:"senderClientId,omitempty"`
}

Signaling msg format for Reception

type WebSocketSignalingMessageSend

type WebSocketSignalingMessageSend struct {
	MessageType       MessageType `json:"action,omitempty"`
	MessagePayload    string      `json:"messagePayload,omitempty"`
	RecipientClientID string      `json:"recipientClientId,omitempty"`
}

Signaling msg format for Sending

Jump to

Keyboard shortcuts

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