Documentation ¶
Index ¶
Constants ¶
const ( REGISTEROK string = `{"Status": "ok!"}` REGISTERER string = `Wrong user name or token.` REGISTEROL string = `Your device is already online.` REGISTERTO string = `Id authentication is required.` PBPUSHNERR string = `Fail to send Pushbullet notification.` HANDLERFER string = `An error occurred on running custom handler function.` MESSAGEERR string = `Missing source or destination.` )
Constant strings for return request/message status.
Variables ¶
This section is empty.
Functions ¶
func IPAddress ¶
IPAddress returns host system's IP address. It does not return loopback address (localhost). If there is not any public IP address, it will return local area network address.
func InitDatabase ¶
func InitDatabase(databasePath string)
InitDatabase Initializes a new SQLite database file. It is only utilized for first time initialization. If you have already initialized a database file, please run OpenDatabase() instead.
func IsDatabaseConnected ¶
func IsDatabaseConnected() bool
IsDatabaseConnected checks if database is opened.
Types ¶
type Core ¶
type Core struct { // Server's domain name. Domain string // Port number listened by Akari Message Framework. Port string // Domain's certificate chain. CertChain string // Domain's privatekey. CertKey string // Relative path for handling HTTP POST requests. MessageRelativePath string // Relative path for providing websocket service. WebsocketRelativePath string // Path to SQLite database file. DatabasePath string // Event is a map points to your custom functions. Event map[string]HandlerFunc }
Core is the framework's instance, it contains all configuration settings. Create an instance of Core, by using New().
func New ¶
func New() *Core
New returns a new blank Core instance. By default the configuration is: Domain: your host system's IP address (Not localhost). Port: "8080". MessageRelativePath: "/nc". WebsocketRelativePath: "/ws". Note: You need set DatabasePath before Run().
func (Core) OpenDatabase ¶
func (c Core) OpenDatabase()
OpenDatabase opens an exist SQLite database file.
type HandlerFunc ¶
HandlerFunc is the type of custom function.
type Message ¶
type Message struct { // Message sender's token. Source string // Message receiver's token. Destination []string // Message content. Data map[string]string }
Message defines "Unified Message Format". Examples could be found on https://github.com/nrechn/akari .
func ReadMessage ¶
ReadMessage reads a string of Message content, and returns in Message type.
type PushbulletPush ¶
type PushbulletPush struct { // Type of the push, one of "note", "file", "link". // Akari currently only supports type "note". PushType string // Title of the push, used for all types of pushes. Title string // Body of the push, used for all types of pushes. Body string // Access Token of your account. AccessToken string }
PushbulletPush defines Pushbullet's push action (notification).
func (*PushbulletPush) Push ¶
func (p *PushbulletPush) Push() (err error)
Push sends a POST request to Pushbullet server in order to make a Pushbullet push notification.
type User ¶
type User struct { // Name of a user. Name string // Token is usually generated by system. Token string }
User defines user information.
func (User) IsUser ¶
IsUser checks if given user information is exist in database/system. It accepts one of user information, or both "Name" and "Token". Return true for exist; false for not exist.
func (User) RegisterUser ¶
RegisterUser registers a new user to database. It only accepts username with empty "Token". Return username, user's new token, error.
func (*User) UserCompletion ¶
UserCompletion complets user information. Give one of user information, it will fill the missing value. Return error if giving both "Name" and "Token", or user is not found.