{"modulePath":"github.com/koding/kite","version":"v0.0.0-20180710021347-baa1a54919e3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package protocol\n\nPackage protocol defines the communication between the components of the Kite infrastructure. It defines some constants and structures designed to be sent between those components.\n\n## Types\n\n```go\ntype Auth struct {\n\t// Type can be \"kiteKey\", \"token\" or \"sessionID\" for now.\n\tType string `json:\"type\"`\n\tKey  string `json:\"key\"`\n}\n```\n\n```go\ntype GetKitesArgs struct {\n\tQuery         *KontrolQuery   `json:\"query\"`\n\tWatchCallback dnode.Function  `json:\"watchCallback\"`\n\tWho           json.RawMessage `json:\"who\"`\n}\n```\n\n```go\ntype GetKitesResult struct {\n\tKites []*KiteWithToken `json:\"kites\"`\n}\n```\n\n```go\ntype GetTokenArgs struct {\n\tKontrolQuery // kite to generate a token for\n\n\tForce bool `json:\"force\"` // force creation of a new token\n}\n```\nGetTokenArgs is a request value for the \"getToken\" kontrol method.\n\n```go\ntype Kite struct {\n\t// Short name identifying the type of the kite. Example: fs, terminal...\n\tName string `json:\"name\"`\n\n\t// Owner of the Kite\n\tUsername string `json:\"username\"`\n\n\t// Every Kite instance has different identifier.\n\t// If a kite is restarted, it's id will change.\n\t// This is generated on the Kite.\n\tID string `json:\"id\"`\n\n\t// Environment is defines as something like \"production\", \"testing\",\n\t// \"staging\" or whatever.  This allows you to differentiate between a\n\t// cluster of kites.\n\tEnvironment string `json:\"environment\"`\n\n\t// Region of the kite it is running. Like \"Europe\", \"Asia\" or some other\n\t// locations.\n\tRegion string `json:\"region\"`\n\n\t// 3-digit semantic version.\n\tVersion string `json:\"version\"`\n\n\t// os.Hostname() of the Kite.\n\tHostname string `json:\"hostname\"`\n}\n```\nKite 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: username.environment.name.version.region.hostname.id\n\n```go\nfunc KiteFromString(s string) (*Kite, error)\n```\nKiteFromString returns a new Kite string from the given string representation in the form of \"/username/environment/...\". It's the inverse of k.String()\n\n```go\nfunc (k *Kite) Query() *KontrolQuery\n```\nQuery() returns a pointer to KontrolQuery struct.\n\n```go\nfunc (k Kite) String() string\n```\n\n```go\nfunc (k *Kite) Validate() error\n```\n\n```go\nfunc (k *Kite) Values() []string\n```\nValues returns the values of each field in order\n\n```go\ntype KiteAction string\n```\n\n```go\nconst (\n\tRegister   KiteAction = \"REGISTER\"\n\tDeregister KiteAction = \"DEREGISTER\"\n)\n```\n\n```go\ntype KiteEvent struct {\n\tAction KiteAction `json:\"action\"`\n\tKite   Kite       `json:\"kite\"`\n\n\t// Required to connect when Action == Register\n\tURL   string `json:\"url,omitempty\"`\n\tToken string `json:\"token,omitempty\"`\n}\n```\nKiteEvent is the struct that is sent as an argument in watchCallback of getKites method of Kontrol.\n\n```go\ntype KiteWithToken struct {\n\tKite  Kite   `json:\"kite\"`\n\tURL   string `json:\"url\"`\n\tKeyID string `json:\"keyId,omitempty\"`\n\tToken string `json:\"token\"`\n}\n```\n\n```go\ntype KontrolQuery struct {\n\tUsername    string `json:\"username\"`\n\tEnvironment string `json:\"environment\"`\n\tName        string `json:\"name\"`\n\tVersion     string `json:\"version\"`\n\tRegion      string `json:\"region\"`\n\tHostname    string `json:\"hostname\"`\n\tID          string `json:\"id\"`\n}\n```\nKontrolQuery 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.\n\n```go\nfunc (k KontrolQuery) Fields() map[string]string\n```\n\n```go\ntype Payload struct {\n\tMsg *string `json:\"msg,omitempty\"`\n\tSdp *struct {\n\t\tType *string `json:\"type,omitempty\"`\n\t\tSdp  *string `json:\"sdp,omitempty\"`\n\t} `json:\"sdp,omitempty\"`\n\tType          *string `json:\"type,omitempty\"`\n\tLabel         *string `json:\"label,omitempty\"`\n\tConnectionID  *string `json:\"connectionId,omitempty\"`\n\tReliable      *bool   `json:\"reliable,omitempty\"`\n\tSerialization *string `json:\"serialization,omitempty\"`\n\tBrowser       *string `json:\"browser,omitempty\"`\n\tCandidate     *struct {\n\t\tCandidate     *string `json:\"candidate,omitempty\"`\n\t\tSdpMid        *string `json:\"sdpMid,omitempty\"`\n\t\tSdpMLineIndex *int    `json:\"sdpMLineIndex,omitempty\"`\n\t} `json:\"candidate,omitempty\"`\n}\n```\nPayload is the content of \\`payload\\` in the json\n\n```go\ntype RegisterArgs struct {\n\tURL  string `json:\"url\"`\n\tKite *Kite  `json:\"kite,omitempty\"`\n\tAuth *Auth  `json:\"auth,omitempty\"`\n}\n```\nRegisterArgs is used as the function argument to the Kontrol's register method.\n\n```go\ntype RegisterResult struct {\n\tURL               string `json:\"url\"`\n\tHeartbeatInterval int64  `json:\"heartbeatInterval\"`\n\tError             string `json:\"err,omitempty\"`\n\n\t// PublicKey is only available if the public Key of the request is\n\t// invalid.\n\tPublicKey string `json:\"publicKey,omitempty\"`\n\n\t// KiteKey is non-empty when caller made a request using kitekey\n\t// signed by a keypair that was recently deleted.\n\t//\n\t// In such case Kontrol is going to create new kite key by signing\n\t// it with new keys.\n\tKiteKey string `json:\"kiteKey,omitempty\"`\n}\n```\nRegisterResult is a response to Register request from Kite to Kontrol.\n\n```go\ntype WebRTCSignalMessage struct {\n\tType    string          `json:\"type,omitempty\"`\n\tSrc     string          `json:\"src,omitempty\"`\n\tDst     string          `json:\"dst,omitempty\"`\n\tPayload json.RawMessage `json:\"payload,omitempty\"`\n\t// contains filtered or unexported fields\n}\n```\nWebRTCSignalMessage represents a signalling message between peers and the singalling server\n\n```go\nfunc ParseWebRTCSignalMessage(msg string) (*WebRTCSignalMessage, error)\n```\nParseWebRTCSignalMessage parses the web rtc command/message\n\n```go\nfunc (w *WebRTCSignalMessage) ParsePayload() (*Payload, error)\n```\nParsePayload parses the payload if it is not parsed previously. This method can be called concurrently.\n\n```go\ntype WhoResult struct {\n\tQuery *KontrolQuery `json:\"query\"`\n}\n```\n\n","path":"github.com/koding/kite/protocol","name":"protocol","synopsis":"Package protocol defines the communication between the components of the Kite infrastructure.","isRedistributable":true}
