Files
openfsd/handler/result.go
Reese Norris 57d54d6705 v0.1.0-alpha
Changes:
- Implement bootstrapping library for managing several concurrent internal services
- Refactor concurrency model for connections/logical clients and their associated I/O
- Refactor server context singleton
- Refactor error handling
    - Most errors are now gracefully sent to the FSD client directly encoded as an $ER packet,
      enhancing visibility and debugging
    - Most errors are now rightfully treated as non-fatal
- Refactor package/dependency graph
- Refactor calling conventions/interfaces for many packages
- Refactor database package
- Refactor post office

Features:
- Add VATSIM-esque HTTP/JSON "data feed"
- Add ephemeral in-memory database option
- Add user management REST API
- Add improved web interface
- Add MySQL support (drop SQLite support)
2024-10-07 12:50:39 -07:00

49 lines
1.2 KiB
Go

package handler
import "github.com/renorris/openfsd/postoffice"
// Result represents the result of a handler function
type Result struct {
replies []string
mail []postoffice.Mail
disconnectFlag bool
}
// Replies returns the slice of reply packets.
// Return value may be nil.
func (r *Result) Replies() []string {
return r.replies
}
// MailingList returns the slice of mail.
// Return value may be nil.
func (r *Result) MailingList() []postoffice.Mail {
return r.mail
}
// DisconnectFlag returns whether the flag is set indicating to disconnect the client
func (r *Result) DisconnectFlag() bool {
return r.disconnectFlag
}
// setDisconnectFlag sets the disconnect flag to true, which will signal the event loop to disconnect the client
func (r *Result) setDisconnectFlag() {
r.disconnectFlag = true
}
// addReply adds a packet to be sent back to the caller client
func (r *Result) addReply(packet string) {
if r.replies == nil {
r.replies = make([]string, 0, 1)
}
r.replies = append(r.replies, packet)
}
// AddMail adds mail to be sent to other clients
func (r *Result) addMail(mail postoffice.Mail) {
if r.mail == nil {
r.mail = make([]postoffice.Mail, 0, 1)
}
r.mail = append(r.mail, mail)
}