opentok

package module
v0.0.0-...-1ed1f81 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2018 License: MIT Imports: 14 Imported by: 0

README

opentok

OpenTok


(WIP) Server side Go SDK for TokBox | OpenTok's REST API.

Documentation

Index

Constants

View Source
const (
	// TokenSentinel ...
	TokenSentinel = "T1=="
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse ...

func CreateSessionEndpoint

func CreateSessionEndpoint() *url.URL

CreateSessionEndpoint constuct create session API endpoint, which should return an *url.URL.

func Decode

func Decode(r *http.Request, data interface{}) error

Decode should decode the response data into provided interface value.

func Endpoint

func Endpoint(parts ...string) *url.URL

Endpoint should construct API endpoint, which would return an *url.URL.

func IsZero

func IsZero(v reflect.Value) bool

IsZero determines whether or not a variable/field/whatever is of it's type's zero value pass reflect.ValueOf(x). http://stackoverflow.com/a/23555352/3183170

Types

type Archive

type Archive struct {

	// CreatedAt represents unix timestamp that specified when the archive was
	// created.
	CreatedAt int64 `json:"createdAt"`

	// Duration of the archive in seconds.
	Duration int64 `json:"duration"`

	// ID of the archive. This is a unique id identifier for the archive.
	// It's used to stop, retrieve and delete archives.
	ID string `json:"id"`

	// Name for the archive. The user can choose any name but it doesn't
	// necessarily need to be different between archives.
	Name string `json:"name"`

	// APIKey to which the archive belongs.
	APIKey int `json:"partnerId"`

	// SessionID to which the archive belongs.
	SessionID string `json:"sessionId"`

	// Size of the archives in KB.
	Size int `json:"size"`

	// URL from where the archive can be retrieved. This is only useful if the
	// archive is in status available in the OpenTok S3 Account.
	URL string `json:"url"`

	// Status of the Archive.
	// The possibilities are:
	// - `started`:   if the archive is being recorded
	// - `stopped`:   if the archive has been stopped and it hasn't been uploaded or available
	// - `deleted`:   if the archive has been deleted. Only available archives can be deleted
	// - `uploaded`:  if the archive has been uploaded to the partner storage account
	// - `paused`:    if the archive has not been stopped but it is not recording. It can transition to Started again
	// - `available`: if the archive has been uploaded to the OpenTok S3 account
	// - `expired`:   available archives are removed from the OpenTok S3 account after 3 days. Their status become expired.
	Status string `json:"status"`

	// HasAudio tells whether the archive contains an audio stream.
	HasAudio bool `json:"hasAudio"`

	// HasVideo tells whether the archive contains a video stream.
	HasVideo bool `json:"hasVideo"`
}

Archive holds all the information retrieved from the server.

type ArchiveList

type ArchiveList struct {
	Count    int       `json:"count"`
	Archives []Archive `json:"items"`
}

ArchiveList will hold the list of archives retrieved from opentok service.

type ArchiveMode

type ArchiveMode string

ArchiveMode denotes different modes for an archive. Ref: https://tokbox.com/developer/rest/#start_archive

const (
	// ArchiveModeManual is the string representation of archive mode status `manual`.
	ArchiveModeManual ArchiveMode = "manual"

	// ArchiveModeAlways is the string representation of archive mode status `always`.
	ArchiveModeAlways ArchiveMode = "always"
)

type Claims

type Claims struct {
	IST string `json:"ist,omitempty"`
	jwt.StandardClaims
}

Claims ... Ref: https://tokbox.com/developer/rest/#authentication

type Exception

type Exception struct {
	Status   int    `json:"status"`
	Message  string `json:"message"`
	Code     int    `json:"code"`
	MoreInfo string `json:"more_info"`
}

Exception holds information about error response.

func (*Exception) Error

func (e *Exception) Error() string

Exception implements Error interface

type OpenTok

type OpenTok struct {
	// APIKey that you get after creating a project at the `OpenTok Dashboard`.
	APIKey int

	// APISecret that you get after creating a project with the `OpenTok Dashboard`.
	APISecret string

	// PartnerAuth ...
	PartnerAuth string

	// UserAgent ...
	UserAgent string

	Client httpClient
}

OpenTok holds all the necessary information to create sessions and interact with the OpenTok platform.

func (*OpenTok) AuthenticationKey

func (openT *OpenTok) AuthenticationKey() (string, error)

AuthenticationKey ...

func (*OpenTok) CreateSession

func (openT *OpenTok) CreateSession(location, archiveMode string) (
	*Session, error,
)

CreateSession should generate a new session. Sample Response: [

{
    "properties": null,
    "session_id": "1_MX40NjEwNTE4Mn5-MTUyNTAzMTQzNTUyMX4wczhaSThsS3VoVzY2eWxiRkFlN2srZFB-fg",
    "project_id": "46105182",
    "partner_id": "46105182",
    "create_dt": "Sun Apr 29 12:50:35 PDT 2018",
    "session_status": null,
    "status_invalid": null,
    "media_server_hostname": null,
    "messaging_server_url": null,
    "messaging_url": null,
    "symphony_address": null,
    "ice_server": null,
    "ice_servers": null,
    "ice_credential_expiration": 86100
}

]

func (*OpenTok) New

func (openT *OpenTok) New(apiKey int, apiSecret string, httpClient *http.Client) *OpenTok

New creates a new OpenTok object.

func (*OpenTok) NewRequest

func (openT *OpenTok) NewRequest(
	method string, u *url.URL, body io.Reader, withAuth bool,
) (*http.Request, error)

NewRequest should make a request to particular API endpoint with provided method.

type Pagination

type Pagination struct {
	Page            int    `json:"page"`
	NumPages        int    `json:"num_pages"`
	PageSize        int    `json:"page_size"`
	Total           int    `json:"total"`
	Start           int    `json:"start"`
	End             int    `json:"end"`
	URI             string `json:"uri"`
	FirstPageURI    string `json:"first_page_uri"`
	PreviousPageURI string `json:"previous_page_uri"`
	NextPageURI     string `json:"next_page_uri"`
	LastPageURI     string `json:"last_page_uri"`
}

Pagination ...

type Response

type Response struct {
	*http.Response
	Pagination
}

Response ...

func NewResponse

func NewResponse(r *http.Response) *Response

NewResponse ...

type Session

type Session struct {
	Properties string `json:"properties,omitempty"`

	SessionID  string `json:"session_id,omitempty"`
	ProjectID  string `json:"project_id,omitempty"`
	PartnerID  string `json:"partner_id,omitempty"`
	CreateDate string `json:"create_dt"`

	SessionStatus  string `json:"session_status,omitempty"`
	SessionInvalid string `json:"session_invalid,omitempty"`

	MediaServerHostname string `json:"media_server_hostname,omitempty"`
	MessagingServerURL  string `json:"messaging_server_url,omitempty"`
	MessagingURL        string `json:"messaging_url,omitempty"`

	SymphonyAddress         string `json:"symphony_address,omitempty"`
	IceServer               string `json:"ice_server,omitempty"`
	IceServers              string `json:"ice_servers,omitempty"`
	IceCredentialExpiration int    `json:"ice_credential_expiration,omitempty"`
}

Session represents a single session for the clients to communicate.

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp ...

func (Timestamp) Equal

func (t Timestamp) Equal(m Timestamp) bool

Equal ...

func (*Timestamp) IsZero

func (t *Timestamp) IsZero() bool

IsZero ...

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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