simulation

package
v0.0.0-...-8567bd0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package simulation contains utilities for simulating clients

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartBot

func StartBot(opts BotOptions)

StartBot ...

Types

type AvgFreq

type AvgFreq struct {
	Total   time.Duration
	Samples uint16
	Last    time.Time
}

AvgFreq is used to track the avg frequency between messages

func (*AvgFreq) Avg

func (a *AvgFreq) Avg() float64

Avg return the avg frequency between message

func (*AvgFreq) Seen

func (a *AvgFreq) Seen(t time.Time)

Seen is called when a new message is received

type BotOptions

type BotOptions struct {
	CoordinatorURL string
	Topic          string
	Subscription   map[string]bool
	TrackStats     bool
	Log            zerolog.Logger
}

BotOptions ...

type Client

type Client struct {
	SendReliable        chan []byte
	SendUnreliable      chan []byte
	StopReliableQueue   chan bool
	StopUnreliableQueue chan bool
	PeerData            chan peerData
	// contains filtered or unexported fields
}

Client represents a peer with role CLIENT

func MakeClient

func MakeClient(config *Config) *Client

MakeClient creates a new client

func Start

func Start(config *Config) *Client

Start starts a new client

func (*Client) Connect

func (client *Client) Connect(alias uint64, serverAlias uint64) error

Connect connect to specified server

func (*Client) SendTopicSubscriptionMessage

func (client *Client) SendTopicSubscriptionMessage(topics map[string]bool) error

SendTopicSubscriptionMessage sends a topic subscription message to the comm server

type Config

type Config struct {
	ICEServers        []pion.ICEServer
	Auth              authentication.ClientAuthenticator
	OnMessageReceived func(reliable bool, msgType protocol.MessageType, raw []byte)
	CoordinatorURL    string
	Log               logging.Logger
}

Config is the client config

type Stats

type Stats struct {
	LastSeen time.Time
	// contains filtered or unexported fields
}

Stats is the main stats structure

func (*Stats) Avg

func (s *Stats) Avg() float64

Avg return the avg frequency between message

func (*Stats) Samples

func (s *Stats) Samples() uint16

Samples return the amount of collected samples so far

func (*Stats) Seen

func (s *Stats) Seen(t time.Time)

Seen is called when a new message is received

Jump to

Keyboard shortcuts

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