Documentation ¶
Index ¶
- func Serve(address string, path string, fact func() BBS)
- type AccessInfo
- type BBS
- type BBSCommand
- type BoardListMessage
- type BoardListing
- type Boards
- type Bookmark
- type BookmarkListMessage
- type Bookmarks
- type ErrorMessage
- type GetCommand
- type HelloMessage
- type ListCommand
- type ListMessage
- type ListenCommand
- type Listener
- type LoginCommand
- type LogoutCommand
- type Message
- type OKMessage
- type PostCommand
- type Range
- type Realtime
- type RegisterCommand
- type ReplyCommand
- type Server
- type Session
- type SessionHandler
- func (sh *SessionHandler) Add(sesh *Session)
- func (sh *SessionHandler) Copy(from *Session, to *Session)
- func (sh *SessionHandler) Get(sesh string) *Session
- func (sh *SessionHandler) Logout(sesh string)
- func (sh *SessionHandler) Touch(sesh string)
- func (sh *SessionHandler) TryLogin(m LoginCommand) *Session
- func (sh *SessionHandler) Upgrade(sesh *Session, m LoginCommand) bool
- type ThreadListing
- type ThreadMessage
- type TypedMessage
- type UnknownHandler
- type UserCommand
- type WelcomeMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessInfo ¶
type AccessInfo struct { GuestCommands []string `json:"guest,omitempty"` UserCommands []string `json:"user,omitempty"` }
guest commands are commands you can use without logging on (e.g. "list", "get") user commands require being logged in first (usually "post" and "reply")
type BBS ¶
type BBS interface { Hello() HelloMessage Register(m RegisterCommand) (OKMessage, error) LogIn(m LoginCommand) bool LogOut(m LogoutCommand) OKMessage IsLoggedIn() bool Get(m GetCommand) (ThreadMessage, error) List(m ListCommand) (ListMessage, error) Reply(m ReplyCommand) (OKMessage, error) Post(m PostCommand) (OKMessage, error) }
type BBSCommand ¶
type BBSCommand struct {
Command string `json:"cmd"`
}
type BoardListMessage ¶
type BoardListMessage struct { Command string `json:"cmd"` Type string `json:"type"` Query string `json:"query,omitempty"` Boards []BoardListing `json:"boards"` }
"list" message where type = "board" (server -> client)
type BoardListing ¶
type BoardListing struct { ID string `json:"id"` Name string `json:"name,omitempty"` Description string `json:"desc,omitempty"` ThreadCount int `json:"threads,omitempty"` PostCount int `json:"posts,omitempty"` Date string `json:"date,omitempty"` }
format for boards in "list"
type Boards ¶
type Boards interface {
BoardList(m ListCommand) (BoardListMessage, error)
}
type BookmarkListMessage ¶
type Bookmarks ¶
type Bookmarks interface {
BookmarkList(m ListCommand) (BookmarkListMessage, error)
}
type ErrorMessage ¶
type ErrorMessage struct { Command string `json:"cmd"` ReplyTo string `json:"wrt"` Error string `json:"error"` }
"error" message (server -> client)
var SessionErrorMessage ErrorMessage = Error("session", "bad session")
session expired or invalid? use this
func Error ¶
func Error(wrt, msg string) ErrorMessage
type GetCommand ¶
type GetCommand struct { Command string `json:"cmd"` Session string `json:"session,omitempty"` ThreadID string `json:"id"` Range Range `json:"range"` //option: "range" Filter string `json:"filter,omitempty"` //option: "filter" Format string `json:"format,omitempty"` Token string `json:"token,omitempty"` }
"get" command (client -> server)
type HelloMessage ¶
type HelloMessage struct { Command string `json:"cmd"` Name string `json:"name"` ProtocolVersion int `json:"version"` Description string `json:"desc"` SecureURL string `json:"secure,omitempty"` //https URL, if any Options []string `json:"options,omitempty"` Access AccessInfo `json:"access"` Formats []string `json:"format"` //formats the server accepts, the first one should be the primary one Lists []string `json:"lists"` ServerVersion string `json:"server"` IconURL string `json:"icon"` // for option "range" DefaultRange Range `json:"default_range,omitempty"` // for option "realtime" RealtimeURL string `json:"realtime"` }
"hello" message (server -> client)
type ListCommand ¶
type ListCommand struct { Command string `json:"cmd"` Session string `json:"session,omitempty"` Type string `json:"type"` Query string `json:"query"` //board for "boards", tag expression for "tags" (like "Dogs+Pizza-Anime") Token string `json:"token,omitempty"` }
"list" command (client -> server)
type ListMessage ¶
type ListMessage struct { Command string `json:"cmd"` Type string `json:"type"` Query string `json:"query,omitempty"` Threads []ThreadListing `json:"threads"` NextToken string `json:"next,omitempty"` }
"list" message where type = "thread" (server -> client)
type ListenCommand ¶
type LoginCommand ¶
type LoginCommand struct { Command string `json:"cmd"` Username string `json:"username"` Password string `json:"password"` ProtocolVersion int `json:"version"` // for "re-logins" only Session string `json:"session,omitempty"` }
"login" command (client -> server)
type LogoutCommand ¶
"logout" command (client -> server)
type Message ¶
type Message struct { ID string `json:"id"` Author string `json:"user"` AuthorID string `json:"user_id,omitempty"` Date string `json:"date,omitempty"` Text string `json:"body"` Signature string `json:"sig,omitempty"` AuthorTitle string `json:"user_title,omitempty"` //option: "usertitles" AvatarURL string `json:"avatar,omitempty"` //option: "avatars" AvatarThumbnailURL string `json:"avatar_thumb,omitempty"` //option: "avatars" PictureURL string `json:"img,omitempty"` //option: "imageboard" ThumbnailURL string `json:"thumb,omitempty"` //option: "imageboard" }
format for posts used in "msg"
type OKMessage ¶
type OKMessage struct { Command string `json:"cmd"` ReplyTo string `json:"wrt"` Result string `json:"result,omitempty"` }
"ok" message (server -> client)
type PostCommand ¶
type PostCommand struct { Command string `json:"cmd"` Session string `json:"session,omitempty"` Title string `json:"title"` Text string `json:"body"` Format string `json:"format,omitempty"` Board string `json:"board,omitempty"` //option: "boards" Tags []string `json:"tags,omitempty"` //option: "tags" }
"post" command (client -> server)
type Realtime ¶
type Realtime interface { Listen(m ListenCommand) (OKMessage, error) Part(m ListenCommand) (OKMessage, error) // server stuff Connect(Listener) Bye() }
type RegisterCommand ¶
type RegisterCommand struct { Command string `json:"cmd"` Username string `json:"username"` Password string `json:"password"` Email string `json:"email,omitempty"` }
"register" command (client -> server)
type ReplyCommand ¶
type ReplyCommand struct { Command string `json:"cmd"` Session string `json:"session,omitempty"` To string `json:"to"` Text string `json:"body"` Format string `json:"format,omitempty"` }
"reply" command (client -> server)
type Server ¶
type Server struct { Sessions *SessionHandler Name string WS http.Handler // contains filtered or unexported fields }
func (*Server) DefaultBBS ¶
func (*Server) ServeWebsocket ¶
type SessionHandler ¶
type SessionHandler struct { Server *Server // contains filtered or unexported fields }
func NewSessionHandler ¶
func NewSessionHandler(srv *Server) *SessionHandler
func (*SessionHandler) Add ¶
func (sh *SessionHandler) Add(sesh *Session)
func (*SessionHandler) Copy ¶
func (sh *SessionHandler) Copy(from *Session, to *Session)
func (*SessionHandler) Get ¶
func (sh *SessionHandler) Get(sesh string) *Session
func (*SessionHandler) Logout ¶
func (sh *SessionHandler) Logout(sesh string)
func (*SessionHandler) Touch ¶
func (sh *SessionHandler) Touch(sesh string)
func (*SessionHandler) TryLogin ¶
func (sh *SessionHandler) TryLogin(m LoginCommand) *Session
func (*SessionHandler) Upgrade ¶
func (sh *SessionHandler) Upgrade(sesh *Session, m LoginCommand) bool
type ThreadListing ¶
type ThreadListing struct { ID string `json:"id"` Title string `json:"title"` Author string `json:"user,omitempty"` AuthorID string `json:"user_id,omitempty"` Date string `json:"date,omitempty"` PostCount int `json:"posts,omitempty"` UnreadPosts int `json:"unread_posts,omitempty"` Sticky bool `json:"sticky,omitempty"` //a sticky (aka pinned) topic Closed bool `json:"closed,omitempty"` //a closed (aka locked) topic Tags []string `json:"tags,omitempty"` //option: "tags" PictureURL string `json:"img,omitempty"` //option: "imageboard" ThumbnailURL string `json:"thumb,omitempty"` //option: "imageboard" }
format for threads in "list"
type ThreadMessage ¶
type ThreadMessage struct { Command string `json:"cmd"` ID string `json:"id" bson:"_id"` Title string `json:"title,omitempty"` Range Range `json:"range,omitempty"` Closed bool `json:"closed,omitempty"` Filter string `json:"filter,omitempty"` //option: "filter" Board string `json:"board,omitempty"` //option: "boards" Tags []string `json:"tags,omitempty"` //option: "tags" Format string `json:"format,omitempty"` Messages []Message `json:"messages"` Total int `json:"total,omitempty"` More bool `json:"more,omitempty"` NextToken string `json:"next,omitempty"` }
"msg" message (server -> client) [response to "get"]
func (ThreadMessage) Size ¶
func (t ThreadMessage) Size() int
type TypedMessage ¶
type UnknownHandler ¶
type UserCommand ¶
type WelcomeMessage ¶
type WelcomeMessage struct { Command string `json:"cmd"` Username string `json:"username,omitempty"` //omit for option 'anon' Session string `json:"session"` }
"welcome" message (server -> client)