Documentation ¶
Index ¶
- Constants
- type API
- type BaseAPI
- func (b *BaseAPI) AddSocket(socket Socket)
- func (b *BaseAPI) AddStopChan() chan bool
- func (b *BaseAPI) Configure(message ClientMessage) error
- func (b *BaseAPI) Data() (interface{}, error)
- func (b *BaseAPI) GetName() string
- func (b *BaseAPI) GetPosition() Position
- func (b *BaseAPI) GetSockets() map[Socket]bool
- func (b *BaseAPI) GetUUID() uuid.UUID
- func (b *BaseAPI) Init(name string, sockets map[Socket]bool, pool Pool, id uuid.UUID)
- func (b *BaseAPI) Run()
- func (b *BaseAPI) Running() bool
- func (b *BaseAPI) Send(data interface{}, err error)
- func (b *BaseAPI) SetPosition(pos Position)
- func (b *BaseAPI) Stop()
- func (b *BaseAPI) String() string
- type BaseMessage
- type ClientAction
- type ClientMessage
- type ClockConfig
- type ClockResponse
- type CloseType
- type Clouds
- type Coord
- type DataObject
- type ImageDB
- type Main
- type MessageStatus
- type Pool
- type Position
- type Rain
- type SlideShowConfig
- type SlideShowResponse
- type Socket
- type Sys
- type SysInfoConfig
- type SysInfoResponse
- type TaggedImage
- type TextConfig
- type TextResponse
- type TwitterConfig
- type TwitterResponse
- type Unregister
- type Weather
- type WeatherConfig
- type WeatherResponse
- type Wind
Constants ¶
const ( APIWeather string = "weather" APIText = "text" APIClock = "clock" APISlideshow = "slideshow" APITwitter = "twitter" APISysinfo = "sysinfo" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { // Configure settings from raw json message Configure(message ClientMessage) error // Main loop that faciliates interaction between outside world and the client widet Run() // Data gets the data to send Data() (interface{}, error) GetName() string GetUUID() uuid.UUID GetSockets() map[Socket]bool GetPosition() Position SetPosition(Position) Stop() Send(interface{}, error) Running() bool AddSocket(Socket) }
API is the entrance point of all apis to connect to a client
type BaseAPI ¶
type BaseAPI struct { Position Name string UUID uuid.UUID Sockets map[Socket]bool `json:"-"` Pool Pool `json:"-"` CloseChan chan CloseType `json:"-"` ConfigChan chan ClientMessage `json:"-"` StopChans []chan bool `json:"-"` // contains filtered or unexported fields }
BaseAPI base for all APIs
func (*BaseAPI) AddStopChan ¶
func (*BaseAPI) Configure ¶
func (b *BaseAPI) Configure(message ClientMessage) error
Configure based on an incoming client message
func (*BaseAPI) GetSockets ¶
GetSockets returns the apis socket connection
func (*BaseAPI) SetPosition ¶
SetPosition configures position
type BaseMessage ¶
type BaseMessage struct { Position Status MessageStatus Error string `json:",omitempty"` Data interface{} `json:",omitempty"` }
BaseMessage is the base message we are sending to frontend All structs being send to the frontend should inherit from this
type ClientAction ¶
type ClientAction string
ClientAction is fun
const ( ConfigureAPI ClientAction = "ConfigureAPI" ConfigurePosition ClientAction = "ConfigurePosition" Delete ClientAction = "Delete" ChangeAPI ClientAction = "ChangeAPI" Initialize ClientAction = "Init" )
Types of actions
type ClientMessage ¶
type ClientMessage struct { Action ClientAction Position Position Config json.RawMessage Name string }
ClientMessage for configuring
type ClockConfig ¶
type ClockConfig struct {
Location string
}
ClockConfig configuration arguments for clock api
type ClockResponse ¶
type ClockResponse struct { ClockConfig Time int64 }
ClockResponse main format for data coming out of clock api
type DataObject ¶
type DataObject interface { // Build builds the data object Update(interface{}) error // Transform turns the data object into a front-end parsable object Transform() interface{} }
DataObject holds the data from the external API
type ImageDB ¶
type ImageDB struct { // A map of tags to file locations? Images []TaggedImage NumImages int UniqueTags []string // the tag "all" means to show all? }
ImageDB holds the images that we have access to
func NewImageDB ¶
func NewImageDB() *ImageDB
func (*ImageDB) GetNumImages ¶
type Main ¶
type Main struct { Temp float64 FeelsLike float64 TempMin float64 TempMax float64 Pressure float64 Humidity float64 }
Main contains a quick description of weather
type MessageStatus ¶
type MessageStatus string
MessageStatus indicates the broad type of message sent back to the client
const ( StatusSuccess MessageStatus = "success" StatusFailure MessageStatus = "failure" )
Enumerates different possible message statuses
type Pool ¶
type Pool interface { Register(API) Unregister(Unregister) Switch(API, ClientMessage) error Save() Add(string, uuid.UUID, map[Socket]bool) (API, error) GetImageDB() *ImageDB SaveImageDB() }
Pool pool
type Position ¶
type Position struct { X int `json:"x"` Y int `json:"y"` W int `json:"w"` H int `json:"h"` I string `json:"i"` }
Position information for api widgets
type SlideShowConfig ¶
type SlideShowResponse ¶
type SlideShowResponse struct { SlideShowConfig FileImages []string }
type Socket ¶
type Socket interface { // Read information from the client Read() // Send information to the client Send(interface{}) CloseChan() chan bool ConfigChan() chan ClientMessage // SendErrorMessage sends error message SendErrorMessage(error) SendSuccess(interface{}, Position) // Wrappers around underlying websocket connection Close() error RemoteAddr() net.Addr }
Socket interface, needed to avoid circular dependency with Socket package
type SysInfoConfig ¶
type SysInfoConfig struct { }
type SysInfoResponse ¶
type TaggedImage ¶
TaggedImage is an instance of an image with tags
type TextConfig ¶
type TextResponse ¶
type TextResponse struct {
TextConfig
}
type TwitterConfig ¶
type TwitterConfig struct { ConsumerKey string ConsumerSecret string AccessToken string AccessSecret string UserHandle string TweetCount int }
TwitterConfig configuration arguments for twitter api
type TwitterResponse ¶
type TwitterResponse struct { TwitterConfig Tweets []twitter.Tweet }
TwitterResponse main format for data coming out of twitter api
type Unregister ¶
Unregister stores info about which api to unregister, and weather the pool should be saved
type WeatherConfig ¶
WeatherConfig are the config settings for the API
type WeatherResponse ¶
type WeatherResponse struct { WeatherConfig Coord Coord Weather []Weather Base string Main Main Visibility float64 Wind Wind Rain Rain Clouds Clouds DT float64 Sys Sys Timezone float64 ID float64 Name string COD float64 Zipcode float64 }
WeatherResponse is the struct that encodes the API data from our weather API