eyeson

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: MIT Imports: 17 Imported by: 0

README

eyeson go library

A golang client for the eyeson video conferencing API.

eyeson ninja gopher

Usage

// Get your api-key at https://eyeson-team.github.io/api
client, err := eyeson.NewClient(eyesonApiKey)
room, err := client.Rooms.Join("standup meeting", "mike")
room.Links.Gui // https://app.eyeson.team/?sessionToken URL to eyeson web GUI
err = room.WaitReady()
overlayUrl = "https://eyeson-team.github.io/api/images/eyeson-overlay.png"
// Set a foreground image.
err = room.SetLayer(overlayUrl, eyeson.Foreground)
// Send a chat message.
err = room.Chat("Welcome!")

In order to receive events from the running meeting, connect on the observer socket like this:

client, _ := eyeson.NewClient(eyesonApiKey)
room, _ := client.Rooms.Join("standup meeting", "mike")
msgCh, _ := client.Observer.Connect(context.Background(), room.Data.Room.ID)
for {
	select {
	case msg, ok := <-msgCh:
		if !ok {
			fmt.Println("Channel closed. Probably disconnected")
			return
		}
		fmt.Println("Received event type: ", msg.GetType())
		switch m := msg.(type) {
		case *eyeson.Chat:
			fmt.Printf("Chat: %s - %s\n", m.ClientID, m.Content)
		}
	}
}

Development

make test # run go tests
# run an example program that starts a meeting, adds an overlay and sends
# a chat message.
API_KEY=... go run examples/meeting.go
# run an example program that listens for webhooks. please ensure the endpoint
# is public available.
API_KEY=... go run examples/webhook-listener.go <endpoint-url>

Releases

  • 1.3.0 Add Observer functionality
  • master Add Webhook signature
  • 1.1.1 Add Shutdown, Fix Webhook Response Validation
  • 1.1.0 Add Webhook Handling
  • 1.0.0 Initial Release

Documentation

Overview

Package eyeson provides a client to interact with the eyeson video API to start video meetings, create access for participants, control recordings, add media like overlay images, play videos, start and stop broadcasts, send chat messages or assign participants to various layouts.

Index

Constants

View Source
const Background int = -1

Background provides the z-index to represent a background image.

View Source
const Foreground int = 1

Foreground provides the z-index to represent a foreground image.

View Source
const Timeout int = 180

Timeout provides the maximum number of seconds WaitReady will wait for a meeting and user to be ready.

View Source
const WEBHOOK_RECORDING string = "recording_update"
View Source
const WEBHOOK_ROOM string = "room_update"
View Source
const WEBHOOK_SNAPSHOT string = "snapshot_update"

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcast added in v1.3.0

type Broadcast struct {
	ID        string    `json:"id"`
	Platform  string    `json:"platform"`
	PlayerURL string    `json:"player_url"`
	User      EventUser `json:"user"`
	Room      EventRoom `json:"room"`
}

Broadcast contains information of a live-stream broadcast.

type BroadcastUpdate added in v1.3.0

type BroadcastUpdate struct {
	EventBase
	Broadcasts []Broadcast `json:"broadcasts"`
}

BroadcastUpdate event is sent whenever the live-stream broadcasts changes.

type Chat added in v1.3.0

type Chat struct {
	EventBase
	Content   string    `json:"content"`
	ClientID  string    `json:"cid"`
	UserID    string    `json:"user_id"`
	CreatedAt time.Time `json:"created_at"`
}

Chat contains a chat message.

type Client

type Client struct {
	BaseURL *url.URL

	Rooms    *RoomsService
	Webhook  *WebhookService
	Observer *ObserverService
	// contains filtered or unexported fields
}

Client provides methods to communicate with the eyeson API, starting video meetings, adapt configurations and send chat, images, presentations and videos to the meeting.

func NewClient

func NewClient(key string, options ...ClientOption) (*Client, error)

NewClient creates a new client in order to send requests to the eyeson API.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends a request to the eyeson API and prepares the result from the received response.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, data url.Values) (*http.Request, error)

NewRequest prepares a request to be sent to the API.

func (*Client) UserClient

func (c *Client) UserClient() *Client

UserClient provides a client for user requests that use the session access key for authorization.

type ClientOption added in v1.2.4

type ClientOption func(*Client)

ClientOption interface to specify options for client

func WithCustomCAFile added in v1.2.4

func WithCustomCAFile(customCAFile string) ClientOption

WithCustomCAFile Set a custom CA file to be used instead of the system-poool CAs.

func WithCustomEndpoint added in v1.3.0

func WithCustomEndpoint(endpoint string) ClientOption

WithCustomEndpoint Set an endpoint which differs from the official api endpoint.

type EventBase added in v1.3.0

type EventBase struct {
	Type string `json:"type"`
}

EventBase Base for all events. Has only the type field.

func (*EventBase) GetType added in v1.3.0

func (msg *EventBase) GetType() string

GetType retrieve the type. Implements the EventInterface

type EventInterface added in v1.3.0

type EventInterface interface {
	GetType() string
}

EventInterface interface for all event-messages.

type EventRoom added in v1.3.0

type EventRoom struct {
	ID           string        `json:"id"`
	Name         string        `json:"name"`
	Ready        bool          `json:"ready"`
	StartedAt    time.Time     `json:"started_at"`
	Shutdown     bool          `json:"shutdown"`
	GuestToken   string        `json:"guest_token"`
	Options      Options       `json:"options"`
	Participants []Participant `json:"participants"`
	Broadcasts   []Broadcast   `json:"broadcasts"`
}

EventRoom represents the room.

type EventUser added in v1.3.0

type EventUser struct {
	ID       string    `json:"id"`
	Name     string    `json:"name"`
	Guest    bool      `json:"guest"`
	Avatar   string    `json:"avatar"`
	JoinedAt time.Time `json:"joined_at"`
}

EventUser represents an user within the event messages.

type Links struct {
	Self     *string `json:"self"`
	Download *string `json:"download"`
}

Links holds a list of links for the corresponding resource.

type ObserverService added in v1.3.0

type ObserverService service

ObserverService Service to listen and control a room.

func (*ObserverService) Connect added in v1.3.0

func (os *ObserverService) Connect(ctx context.Context, roomID string) (<-chan EventInterface, error)

Connect connects the observer and returns an eventInterface channel on success.

type Options added in v1.3.0

type Options struct {
	ShowNames bool `json:"show_names"`
}

Options Struct containing list of options of the room.

type OptionsUpdate added in v1.3.0

type OptionsUpdate struct {
	EventBase
	Options Options `json:"options"`
}

OptionsUpdate event is sent whenever an option parameter is modified or added via the rest-interface.

type Participant added in v1.3.0

type Participant struct {
	ID     string `json:"id"`
	RoomID string `json:"room_id"`
	Name   string `json:"name"`
	Guest  bool   `json:"guest"`
	Online bool   `json:"online"`
	Avatar string `json:"avatar"`
}

Participant holds informationof a participating user containing its online status.

type ParticipantUpdate added in v1.3.0

type ParticipantUpdate struct {
	EventBase
	Participant Participant `json:"participant"`
}

ParticipantUpdate event is sent whenever the list of participants changes.

type Playback added in v1.3.0

type Playback struct {
	URL    string `json:"url"`
	PlayID string `json:"play_id"`
	Audio  bool   `json:"audio"`
}

Playback represents a playback i.e. media inject into the confserver.

type PlaybackUpdate added in v1.3.0

type PlaybackUpdate struct {
	EventBase
	Playing []Playback `json:"playing"`
}

PlaybackUpdate Sent when a playback was started.

type PodiumPosition added in v1.3.0

type PodiumPosition struct {
	UserID string  `json:"user_id"`
	PlayID *string `json:"play_id"`
	Width  int     `json:"width"`
	Height int     `json:"height"`
	Left   int     `json:"left"`
	Top    int     `json:"top"`
	ZIndex int     `json:"z-index"`
}

PodiumPosition defines an area on the podium wich belongs to the specified user identified by its user-id.

type PodiumUpdate added in v1.3.0

type PodiumUpdate struct {
	EventBase
	Podium []PodiumPosition `json:"podium"`
}

PodiumUpdate event is sent whenever the podium layout or the positioning of participants changes.

type Recording added in v1.3.0

type Recording struct {
	ID string `json:"id"`
	// Unix timestamp
	CreatedAt int       `json:"created_at"`
	Duration  *int      `json:"duration"`
	Links     Links     `json:"links"`
	User      EventUser `json:"user"`
	Room      EventRoom `json:"room"`
}

Recording holds information on a recording.

type RecordingUpdate added in v1.3.0

type RecordingUpdate struct {
	EventBase
	Recording Recording `json:"recording"`
}

RecordingUpdate event is sent whenver recording is started or stopped.

type Room

type Room struct {
	ID         string `json:"id"`
	GuestToken string `json:"guest_token"`
	SIP        SIP    `json:"sip"`
	Shutdown   bool   `json:"shutdown"`
}

Room has attributes for SIP details and GuestToken

type RoomLinks struct {
	Gui       string `json:"gui"`
	GuestJoin string `json:"guest_join"`
	Websocket string `json:"websocket"`
}

RoomLinks provide all public web URLs for a room.

type RoomResponse

type RoomResponse struct {
	AccessKey string    `json:"access_key"`
	Links     RoomLinks `json:"links"`
	Room      Room      `json:"room"`
	User      User      `json:"user"`
	Ready     bool      `json:"ready"`
	Signaling Signaling `json:"signaling"`
}

RoomResponse holds available attributes to a room.

func (*RoomResponse) GetAuthToken added in v1.2.1

func (rr *RoomResponse) GetAuthToken() string

GetAuthToken returns the JWT-Authtoken for authenticating to the sig-service.

func (*RoomResponse) GetClientID added in v1.2.1

func (rr *RoomResponse) GetClientID() string

GetClientID returns the client-id of this signaling entity.

func (*RoomResponse) GetConfID added in v1.2.1

func (rr *RoomResponse) GetConfID() string

GetConfID returns the conf-id to connect to.

func (*RoomResponse) GetDisplayname added in v1.2.1

func (rr *RoomResponse) GetDisplayname() string

func (*RoomResponse) GetSigEndpoint added in v1.2.1

func (rr *RoomResponse) GetSigEndpoint() string

GetSigEndpoint returns the signaling endpoint

func (*RoomResponse) GetStunServers added in v1.2.1

func (rr *RoomResponse) GetStunServers() []string

GetStunServers returns stun info

func (*RoomResponse) GetTurnServerPassword added in v1.2.1

func (rr *RoomResponse) GetTurnServerPassword() string

GetTurnServerPassword returns turn credentials

func (*RoomResponse) GetTurnServerURLs added in v1.2.1

func (rr *RoomResponse) GetTurnServerURLs() []string

GetTurnServerURLs returns turn info

func (*RoomResponse) GetTurnServerUsername added in v1.2.1

func (rr *RoomResponse) GetTurnServerUsername() string

GetTurnServerUsername return turn credentials

type RoomUpdate added in v1.3.0

type RoomUpdate struct {
	EventBase
	Content EventRoom `json:"content"`
}

RoomUpdate event is sent if any of the room properties is changed.

type RoomsService

type RoomsService service

RoomsService provides method Join to start and join a room.

func (*RoomsService) GuestJoin added in v1.2.0

func (srv *RoomsService) GuestJoin(guestToken, id, name, avatar string) (*UserService, error)

GuestJoin creates a new guest user for an active meeting.

func (*RoomsService) Join

func (srv *RoomsService) Join(id string, user string, options map[string]string) (*UserService, error)

Join starts and joins a video meeting. The user string represents a unique identifier, to join as participant. If the same room identifier is provided the participants will join the same meeting. The room identifier can be omitted, the eyeson-api will therefor create a new room for every user joining.

func (*RoomsService) Shutdown added in v1.1.1

func (srv *RoomsService) Shutdown(id string) error

Shutdown force stops a running meeting.

type SIP

type SIP struct {
	URI               string `json:"uri"`
	Domain            string `json:"domain"`
	AuthorizationUser string `json:"authorizationUser"`
	Password          string `json:"password"`
	WSServers         string `json:"wsServers"`
	DisplayName       string `json:"displayName"`
}

SIP contains access details for the protocol used to establish a connection.

type SeppSignaling added in v1.2.1

type SeppSignaling struct {
	ClientID    string       `json:"client_id"`
	AuthToken   string       `json:"auth_token"`
	ConfID      string       `json:"conf_id"`
	Endpoint    string       `json:"endpoint"`
	StunServers []string     `json:"stun_servers"`
	TurnServer  []TurnServer `json:"turn_servers"`
}

SeppSignaling holds information required by the gosepp signaling interface.

type Signaling added in v1.2.1

type Signaling struct {
	Type    string        `json:"type"`
	SigSepp SeppSignaling `json:"options"`
}

Signaling base container for signaling options. So far only type "sepp" is allowed.

type Snapshot added in v1.3.0

type Snapshot struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Links     Links     `json:"links"`
	Creator   EventUser `json:"creator"`
	CreatedAt time.Time `json:"created_at"`
	Room      EventRoom `json:"room"`
}

Snapshot represents a snapshot

type SnapshotUpdate added in v1.3.0

type SnapshotUpdate struct {
	EventBase
	Snapshots []Snapshot `json:"snapshots"`
}

SnapshotUpdate fired whenever a new snapshot ist taken.

type TurnServer added in v1.2.1

type TurnServer struct {
	URLs     []string `json:"urls"`
	Username string   `json:"username"`
	Password string   `json:"password"`
}

TurnServer provides connection info for ICE-Servers

type User

type User struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	SIP  SIP    `json:"sip"`
}

User has information on the current participant that has joined the meeting.

type UserService

type UserService struct {
	Data *RoomResponse
	// contains filtered or unexported fields
}

UserService provides methods a user can perform.

func (*UserService) Chat

func (u *UserService) Chat(content string) error

Chat sends a chat message.

func (*UserService) ClearLayer

func (u *UserService) ClearLayer(zIndex int) error

ClearLayer clears a layer given by the z-index that should be set using the constants Foreground or Background.

func (*UserService) SetLayer

func (u *UserService) SetLayer(imgURL string, zIndex int) error

SetLayer sets a layer image using the given public available URL pointing to an image file. The z-index should be set using the constants Foreground or Background.

func (*UserService) SetLayout

func (u *UserService) SetLayout(layout string, users []string, voiceActivation, showNames bool) error

SetLayout sets a participant podium layout where the layout is either "custom" or "auto". The users list is of user-ids or empty strings for empty participant positions. The flag voiceActivation replaces participants actively by voice detection. The flag showNames show or hides participant name overlays.

func (*UserService) StartBroadcast

func (u *UserService) StartBroadcast(streamURL string) error

StartBroadcast starts a broadcast to the given stream url given by a streaming service like YouTube, Vimeo, and others.

func (*UserService) StartPlayback

func (u *UserService) StartPlayback(playbackURL string, userID string) error

StartPlayback starts a playback using the given public available URL to a video file. The given user id marks the position of the participant that is going to be replaced while the playback is shown.

func (*UserService) StartRecording

func (u *UserService) StartRecording() error

StartRecording starts a recording.

func (*UserService) StopBroadcast

func (u *UserService) StopBroadcast() error

StopBroadcast stops a broadcast.

func (*UserService) StopMeeting

func (u *UserService) StopMeeting() error

StopMeeting stops a meeting for all participants.

func (*UserService) StopRecording

func (u *UserService) StopRecording() error

StopRecording stops a recording.

func (*UserService) WaitReady

func (u *UserService) WaitReady() error

WaitReady waits until a meeting has successfully been started. It has a fixed polling interval of one second. WaitReady responds with an error on timeout or any communication problems.

type Webhook added in v1.1.0

type Webhook struct {
	Type      string `json:"type"`
	Recording struct {
		Id        string `json:"id"`
		Duration  int    `json:"duration"`
		CreatedAt int    `json:"created_at"`
		Links     struct {
			Download string `json:"download"`
		} `json:"links"`
		Room struct {
			Id string `json:"id"`
		}
	} `json:"recording,omitempty"`
	Room struct {
		Id        string    `json:"id"`
		Name      string    `json:"name"`
		StartedAt time.Time `json:"started_at"`
		Shutdown  bool      `json:"shutdown"`
	} `json:"room"`
	Snapshot struct {
		Id        string    `json:"id"`
		Name      string    `json:"name"`
		CreatedAt time.Time `json:"created_at"`
		Links     struct {
			Download string `json:"download"`
		} `json:"links"`
		Room struct {
			Id string `json:"id"`
		}
	} `json:"snapshot,omitempty"`
}

Webhook holds available attributes to a room.

func NewWebhook added in v1.2.0

func NewWebhook(apiKey string, r *http.Request) (*Webhook, error)

type WebhookDetails added in v1.1.0

type WebhookDetails struct {
	Id                string    `json:"id"`
	Url               string    `json:"url"`
	Types             []string  `json:"types"`
	LastRequestSentAt time.Time `json:"last_request_sent_at"`
	LastResponseCode  string    `json:"last_response_code"`
}

WebhookDetails provide configuration details.

type WebhookService added in v1.1.0

type WebhookService service

WebhookService provides method Register and Unregister a webhook.

func (*WebhookService) Get added in v1.1.0

func (srv *WebhookService) Get() (*WebhookDetails, error)

Get provides details about a registered webhook.

func (*WebhookService) Register added in v1.1.0

func (srv *WebhookService) Register(endpoint, types string) error

Register will assign an endpoint URL to the current ApiKey.

func (*WebhookService) Unregister added in v1.1.0

func (srv *WebhookService) Unregister() error

Unregister will clear the current webhook.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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