mirror of
https://github.com/renorris/openfsd
synced 2026-04-30 05:06:05 +08:00
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)
This commit is contained in:
47
client/util.go
Normal file
47
client/util.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"github.com/renorris/openfsd/postoffice"
|
||||
"github.com/renorris/openfsd/protocol"
|
||||
"github.com/renorris/openfsd/servercontext"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (c *FSDClient) sendMOTD() error {
|
||||
lines := strings.Split(servercontext.Config().MOTD, "\n")
|
||||
for _, line := range lines {
|
||||
pdu := protocol.TextMessagePDU{
|
||||
From: protocol.ServerCallsign,
|
||||
To: c.callsign,
|
||||
Message: line,
|
||||
}
|
||||
if err := c.connection.WritePacket(pdu.Serialize()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *FSDClient) broadcastAddPilot() {
|
||||
p := protocol.AddPilotPDU{
|
||||
From: c.callsign,
|
||||
To: protocol.ServerCallsign,
|
||||
CID: c.cid,
|
||||
NetworkRating: c.networkRating,
|
||||
ProtocolRevision: protocol.ProtoRevisionVatsim2022,
|
||||
SimulatorType: c.simulatorType,
|
||||
RealName: c.realName,
|
||||
}
|
||||
mail := postoffice.NewMail(c, postoffice.MailTypeBroadcast, "", p.Serialize())
|
||||
servercontext.PostOffice().SendMail(&mail)
|
||||
}
|
||||
|
||||
func (c *FSDClient) broadcastDeletePilot() {
|
||||
deletePilotPDU := protocol.DeletePilotPDU{
|
||||
From: c.callsign,
|
||||
CID: c.cid,
|
||||
}
|
||||
mail := postoffice.NewMail(c, postoffice.MailTypeBroadcast, "", deletePilotPDU.Serialize())
|
||||
servercontext.PostOffice().SendMail(&mail)
|
||||
}
|
||||
Reference in New Issue
Block a user