channelserver

package
v0.0.0-...-b1f961f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FestivalColourNone = "none"
	FestivalColourRed  = "red"
	FestivalColourBlue = "blue"
)
View Source
const (
	BinaryMessageTypeState = 0
	BinaryMessageTypeChat  = 1
	BinaryMessageTypeEmote = 6
)

MSG_SYS_CAST[ED]_BINARY types enum

View Source
const (
	BroadcastTypeTargeted = 0x01
	BroadcastTypeStage    = 0x03
	BroadcastTypeWorld    = 0x0a
)

MSG_SYS_CAST[ED]_BINARY broadcast types enum

View Source
const (
	CharacterSaveRPPointer = 0x22D16
)

Variables

View Source
var FestivalColourCodes = map[FestivalColour]uint8{
	FestivalColourBlue: 0x00,
	FestivalColourRed:  0x01,
	FestivalColourNone: 0xFF,
}

Functions

func CreateGuild

func CreateGuild(s *Session, guildName string) (int32, error)

Types

type CharacterSaveData

type CharacterSaveData struct {
	CharID         uint32
	RP             uint16
	IsNewCharacter bool
	// contains filtered or unexported fields
}

func GetCharacterSaveData

func GetCharacterSaveData(s *Session, charID uint32) (*CharacterSaveData, error)

func (*CharacterSaveData) BaseSaveData

func (save *CharacterSaveData) BaseSaveData() []byte

func (*CharacterSaveData) CompressedBaseData

func (save *CharacterSaveData) CompressedBaseData(s *Session) ([]byte, error)

func (*CharacterSaveData) Save

func (save *CharacterSaveData) Save(s *Session, transaction *sql.Tx) error

func (*CharacterSaveData) SetBaseSaveData

func (save *CharacterSaveData) SetBaseSaveData(data []byte)

type Config

type Config struct {
	Logger      *zap.Logger
	DB          *sqlx.DB
	ErupeConfig *config.Config
}

Config struct allows configuring the server.

type FestivalColour

type FestivalColour string

type Guild

type Guild struct {
	ID             uint32         `db:"id"`
	Name           string         `db:"name"`
	MainMotto      string         `db:"main_motto"`
	CreatedAt      time.Time      `db:"created_at"`
	MemberCount    uint16         `db:"member_count"`
	RP             uint32         `db:"rp"`
	Comment        string         `db:"comment"`
	FestivalColour FestivalColour `db:"festival_colour"`
	GuildHallType  uint16         `db:"guild_hall"`

	GuildLeader
}

func FindGuildsByName

func FindGuildsByName(s *Session, name string) ([]*Guild, error)

func GetGuildInfoByCharacterId

func GetGuildInfoByCharacterId(s *Session, charID uint32) (*Guild, error)

func GetGuildInfoByID

func GetGuildInfoByID(s *Session, guildID uint32) (*Guild, error)

func (*Guild) AcceptCharacter

func (guild *Guild) AcceptCharacter(s *Session, charID uint32) error

func (*Guild) Apply

func (guild *Guild) Apply(s *Session, charID uint32) error

func (*Guild) ArrangeCharacters

func (guild *Guild) ArrangeCharacters(s *Session, charIDs []uint32) error

func (*Guild) Disband

func (guild *Guild) Disband(s *Session) error

func (*Guild) DonateRP

func (guild *Guild) DonateRP(s *Session, rp uint16, transaction *sql.Tx) (err error)

func (*Guild) RemoveCharacter

func (guild *Guild) RemoveCharacter(s *Session, charID uint32) error

func (*Guild) Save

func (guild *Guild) Save(s *Session) error

type GuildLeader

type GuildLeader struct {
	LeaderCharID uint32 `db:"leader_id"`
	LeaderName   string `db:"leader_name"`
}

type GuildMember

type GuildMember struct {
	GuildID     uint32    `db:"guild_id"`
	CharID      uint32    `db:"character_id"`
	JoinedAt    time.Time `db:"joined_at"`
	Name        string    `db:"name"`
	IsApplicant bool      `db:"is_applicant"`
	IsSubLeader bool      `db:"is_sub_leader"`
	OrderIndex  uint16    `db:"order_index"`
	LastLogin   uint32    `db:"last_login"`
}

func GetCharacterGuildData

func GetCharacterGuildData(s *Session, charID uint32) (*GuildMember, error)

func GetGuildMembers

func GetGuildMembers(s *Session, guildID uint32, applicants bool) ([]*GuildMember, error)

type Server

type Server struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Server is a MHF channel server.

func NewServer

func NewServer(config *Config) *Server

NewServer creates a new Server type.

func (*Server) BroadcastChatMessage

func (s *Server) BroadcastChatMessage(message string)

BroadcastChatMessage broadcasts a simple chat message to all the sessions.

func (*Server) BroadcastMHF

func (s *Server) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session)

BroadcastMHF queues a MHFPacket to be sent to all sessions.

func (*Server) FindSessionByCharID

func (s *Server) FindSessionByCharID(charID uint32) *Session

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown tries to shut down the server gracefully.

func (*Server) Start

func (s *Server) Start() error

Start starts the server in a new goroutine.

type Session

type Session struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Session holds state for the channel server connection.

func NewSession

func NewSession(server *Server, conn net.Conn) *Session

NewSession creates a new Session type.

func (*Session) QueueAck

func (s *Session) QueueAck(ackHandle uint32, data []byte)

QueueAck is a helper function to queue an MSG_SYS_ACK with the given ack handle and data.

func (*Session) QueueSend

func (s *Session) QueueSend(data []byte)

QueueSend queues a packet (raw []byte) to be sent.

func (*Session) QueueSendMHF

func (s *Session) QueueSendMHF(pkt mhfpacket.MHFPacket)

QueueSendMHF queues a MHFPacket to be sent.

func (*Session) QueueSendNonBlocking

func (s *Session) QueueSendNonBlocking(data []byte)

QueueSendNonBlocking queues a packet (raw []byte) to be sent, dropping the packet entirely if the queue is full.

func (*Session) Start

func (s *Session) Start()

Start starts the session packet send and recv loop(s).

type Stage

type Stage struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Stage holds stage-specific information

func NewStage

func NewStage(ID string) *Stage

NewStage creates a new stage with intialized values.

func (*Stage) BroadcastMHF

func (s *Stage) BroadcastMHF(pkt mhfpacket.MHFPacket, ignoredSession *Session)

BroadcastMHF queues a MHFPacket to be sent to all sessions in the stage.

type StageObject

type StageObject struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

StageObject holds infomation about a specific stage object.

Directories

Path Synopsis
compression

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL