kite: Index | Files

package protocol

import ""

Package protocol defines the communication between the components of the Kite infrastructure. It defines some constants and structures designed to be sent between those components.


Package Files

protocol.go webrtc.go

type Auth Uses

type Auth struct {
    // Type can be "kiteKey", "token" or "sessionID" for now.
    Type string `json:"type"`
    Key  string `json:"key"`

type GetKitesArgs Uses

type GetKitesArgs struct {
    Query         *KontrolQuery   `json:"query"`
    WatchCallback dnode.Function  `json:"watchCallback"`
    Who           json.RawMessage `json:"who"`

type GetKitesResult Uses

type GetKitesResult struct {
    Kites []*KiteWithToken `json:"kites"`

type GetTokenArgs Uses

type GetTokenArgs struct {
    KontrolQuery // kite to generate a token for

    Force bool `json:"force"` // force creation of a new token

GetTokenArgs is a request value for the "getToken" kontrol method.

type Kite Uses

type Kite struct {
    // Short name identifying the type of the kite. Example: fs, terminal...
    Name string `json:"name"`

    // Owner of the Kite
    Username string `json:"username"`

    // Every Kite instance has different identifier.
    // If a kite is restarted, it's id will change.
    // This is generated on the Kite.
    ID  string `json:"id"`

    // Environment is defines as something like "production", "testing",
    // "staging" or whatever.  This allows you to differentiate between a
    // cluster of kites.
    Environment string `json:"environment"`

    // Region of the kite it is running. Like "Europe", "Asia" or some other
    // locations.
    Region string `json:"region"`

    // 3-digit semantic version.
    Version string `json:"version"`

    // os.Hostname() of the Kite.
    Hostname string `json:"hostname"`

Kite is the base struct containing the public fields. It is usually embedded in other structs, including the db model. The access model is in the form:

func KiteFromString Uses

func KiteFromString(s string) (*Kite, error)

KiteFromString returns a new Kite string from the given string representation in the form of "/username/environment/...". It's the inverse of k.String()

func (*Kite) Query Uses

func (k *Kite) Query() *KontrolQuery

Query() returns a pointer to KontrolQuery struct.

func (Kite) String Uses

func (k Kite) String() string

func (*Kite) Validate Uses

func (k *Kite) Validate() error

func (*Kite) Values Uses

func (k *Kite) Values() []string

Values returns the values of each field in order

type KiteAction Uses

type KiteAction string
const (
    Register   KiteAction = "REGISTER"
    Deregister KiteAction = "DEREGISTER"

type KiteEvent Uses

type KiteEvent struct {
    Action KiteAction `json:"action"`
    Kite   Kite       `json:"kite"`

    // Required to connect when Action == Register
    URL   string `json:"url,omitempty"`
    Token string `json:"token,omitempty"`

KiteEvent is the struct that is sent as an argument in watchCallback of getKites method of Kontrol.

type KiteWithToken Uses

type KiteWithToken struct {
    Kite  Kite   `json:"kite"`
    URL   string `json:"url"`
    KeyID string `json:"keyId,omitempty"`
    Token string `json:"token"`

type KontrolQuery Uses

type KontrolQuery struct {
    Username    string `json:"username"`
    Environment string `json:"environment"`
    Name        string `json:"name"`
    Version     string `json:"version"`
    Region      string `json:"region"`
    Hostname    string `json:"hostname"`
    ID          string `json:"id"`

KontrolQuery is a structure of message sent to Kontrol. It is used for querying kites based on the incoming field parameters. Missing fields are not counted during the query (for example if the "version" field is empty, any kite with different version is going to be matched). Order of the fields is from general to specific.

func (KontrolQuery) Fields Uses

func (k KontrolQuery) Fields() map[string]string

type Payload Uses

type Payload struct {
    Msg *string `json:"msg,omitempty"`
    Sdp *struct {
        Type *string `json:"type,omitempty"`
        Sdp  *string `json:"sdp,omitempty"`
    }   `json:"sdp,omitempty"`
    Type          *string `json:"type,omitempty"`
    Label         *string `json:"label,omitempty"`
    ConnectionID  *string `json:"connectionId,omitempty"`
    Reliable      *bool   `json:"reliable,omitempty"`
    Serialization *string `json:"serialization,omitempty"`
    Browser       *string `json:"browser,omitempty"`
    Candidate     *struct {
        Candidate     *string `json:"candidate,omitempty"`
        SdpMid        *string `json:"sdpMid,omitempty"`
        SdpMLineIndex *int    `json:"sdpMLineIndex,omitempty"`
    }   `json:"candidate,omitempty"`

Payload is the content of `payload` in the json

type RegisterArgs Uses

type RegisterArgs struct {
    URL  string `json:"url"`
    Kite *Kite  `json:"kite,omitempty"`
    Auth *Auth  `json:"auth,omitempty"`

RegisterArgs is used as the function argument to the Kontrol's register method.

type RegisterResult Uses

type RegisterResult struct {
    URL               string `json:"url"`
    HeartbeatInterval int64  `json:"heartbeatInterval"`
    Error             string `json:"err,omitempty"`

    // PublicKey is only available if the public Key of the request is
    // invalid.
    PublicKey string `json:"publicKey,omitempty"`

    // KiteKey is non-empty when caller made a request using kitekey
    // signed by a keypair that was recently deleted.
    // In such case Kontrol is going to create new kite key by signing
    // it with new keys.
    KiteKey string `json:"kiteKey,omitempty"`

RegisterResult is a response to Register request from Kite to Kontrol.

type WebRTCSignalMessage Uses

type WebRTCSignalMessage struct {
    Type    string          `json:"type,omitempty"`
    Src     string          `json:"src,omitempty"`
    Dst     string          `json:"dst,omitempty"`
    Payload json.RawMessage `json:"payload,omitempty"`
    // contains filtered or unexported fields

WebRTCSignalMessage represents a signalling message between peers and the singalling server

func ParseWebRTCSignalMessage Uses

func ParseWebRTCSignalMessage(msg string) (*WebRTCSignalMessage, error)

ParseWebRTCSignalMessage parses the web rtc command/message

func (*WebRTCSignalMessage) ParsePayload Uses

func (w *WebRTCSignalMessage) ParsePayload() (*Payload, error)

ParsePayload parses the payload if it is not parsed previously. This method can be called concurrently.

type WhoResult Uses

type WhoResult struct {
    Query *KontrolQuery `json:"query"`

Package protocol imports 6 packages (graph) and is imported by 52 packages. Updated 2018-07-15. Refresh now. Tools for package owners.