Documentation ¶
Overview ¶
Package matchmaking implements the Blade II Online matchmaking server.
Package matchmaking implements the Blade II Online matchmaking server.
Package matchmaking implements the Blade II Online matchmaking server.
Package matchmaking implements the Blade II Online matchmaking server.
Package matchmaking implements the Blade II Online matchmaking server.
Index ¶
Constants ¶
const (
// BufferSize is the size of each message queue's buffer.
BufferSize = 2048
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientPair ¶
type ClientPair struct { // Pointer to both clients. Client1 *MMClient Client2 *MMClient // The time at which the ready check began. ReadyStart time.Time // Whether the pair is currently undergoing a ready check. IsReadyChecking bool }
ClientPair is a light wrapper for a pair of client connections.
func NewPair ¶
func NewPair(client1 *MMClient, client2 *MMClient) *ClientPair
NewPair initializes and returns a pointer to a new client pair.
func (*ClientPair) SendMatchConfirmedMessage ¶
func (pair *ClientPair) SendMatchConfirmedMessage(matchID uint64)
SendMatchConfirmedMessage sends a match confirmation message with match ID to both clients.
func (*ClientPair) SendMatchFoundMessage ¶
func (pair *ClientPair) SendMatchFoundMessage()
SendMatchFoundMessage sends a match found message to both clients.
type DisconnectRequest ¶
type DisconnectRequest struct { // A pointer to the client that will be removed. Client *MMClient // The reason for removal. Reason protocol.B2Code // An optional message, to be sent to the client before disconnecting. Message string }
DisconnectRequest is a wrapper for the information required to remove a client from the matchmaking queue.
type MMClient ¶
type MMClient struct { // Database values for this client. DBID uint64 PublicID string MMR int // Whether the client is ready (for ready checking). Ready bool // The time at which the client ready confirmation was received (for ready checking). ReadyTime time.Time // Whether the client is currently waiting for a ready confirmation (for ready checking). IsReadyChecking bool // Whether the other client is ready (for ready checking). AcceptMessageSentToOpponent bool // A unique ID used for sorting - Should be set once connected ClientID uint64 // contains filtered or unexported fields }
MMClient is a container for a websocket connection and its associate player data.
func NewClient ¶
NewClient creates a and retruns a pointer to a new Client, and starts its message pumps in two seperate go routines.
func (*MMClient) Close ¶
Close sends a message to the client, and closes the connection after a delay. The delay is asynchronous, as it is wrapped in a goroutine.
func (*MMClient) SendMessage ¶
SendMessage adds a message to the outbound queue.
func (*MMClient) StartEventLoop ¶
func (client *MMClient) StartEventLoop()
StartEventLoop starts the send and receive pumps for the client, with a separate goroutine for each.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a wrapper for the matchmaking queue
func (*Queue) AddClient ¶
AddClient takes a client and adds it to the matchmaking server to be processed later.
func (*Queue) Broadcast ¶
Broadcast adds a message to the broadcast queue, to be sent to all connected clients.
func (*Queue) Init ¶
func (queue *Queue) Init()
Init initializes the matchmaking server including starting the internal loop.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the matchmaking server itself
func NewServer ¶
func NewServer() *Server
NewServer creates and returns a pointer to a new matchmaking server.