protocol

package
v0.0.0-...-843b749 Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package protocol provides utilities for handling websocket messages.

Package protocol provides utilities for handling websocket messages.

Package protocol provides utilities for handling websocket messages.

Package protocol provides utilities for handling websocket messages.

Package protocol provides utilities for handling websocket messages.

Index

Constants

View Source
const (
	QCTBroadcastMessage uint16 = iota
	QCTDropAll
	QCTChangePollTime
)

Queue Command types.

View Source
const (
	WSMTContinuation Type = 0
	WSMTText              = 1
	WSMTBinary            = 2
)

Types of Websocket Message.

Variables

This section is empty.

Functions

This section is empty.

Types

type B2Code

type B2Code uint16

B2Code is a uint16 typedef for non-system websocket messages.

const (
	WSCConnectionTimeOut      B2Code = 100
	WSCUnknownConnectionError B2Code = 101
	WSCDuplicateConnection    B2Code = 102
)

Connection codes.

const (
	WSCAuthRequest        B2Code = 200
	WSCAuthBadFormat      B2Code = 201
	WSCAuthBadCredentials B2Code = 202
	WSCAuthExpired        B2Code = 203
	WSCAuthBanned         B2Code = 204
	WSCAuthExpected       B2Code = 205
	WSCAuthNotReceived    B2Code = 206
	WSCAuthReceived       B2Code = 207
	WSCAuthSuccess        B2Code = 208
)

Auth codes.

const (
	WSCMatchMakingMatchFound B2Code = 300
	WSCMatchMakingAccept     B2Code = 301
	WSCMatchConfirmed        B2Code = 302
	WSCReadyCheckFailed      B2Code = 303
	WSCJoinedQueue           B2Code = 304
	WSCOpponentAccepted      B2Code = 305
	WSCOpponentDidNotAccept  B2Code = 306
)

MatchMaking codes.

const (
	WSCMatchID                  B2Code = 400
	WSCMatchIDExpected          B2Code = 401
	WSCMatchIDBadFormat         B2Code = 402
	WSCMatchInvalid             B2Code = 403
	WSCMatchExpired             B2Code = 404
	WSCMatchIDReceived          B2Code = 405
	WSCMatchIDNotReceived       B2Code = 406
	WSCMatchIDConfirmed         B2Code = 407
	WSCMatchMultipleConnections B2Code = 408
	WSCMatchFull                B2Code = 409
	WSCMatchJoined              B2Code = 410
	WSCMatchIllegalMove         B2Code = 411
	WSCMatchRelayMessage        B2Code = 412
	WSCMatchMove                B2Code = 413
	WSCMatchData                B2Code = 414
	WSCMatchForfeit             B2Code = 415
	WSCMatchMutualTimeout       B2Code = 416
	WSCMatchTimeOut             B2Code = 417
	WSCMatchWin                 B2Code = 418
	WSCMatchDraw                B2Code = 419
	WSCMatchLoss                B2Code = 420
)

Match codes.

const WSCNone B2Code = 0

WSCNone is a generic all-purpose code. Try to avoid using this unless the message can be safely ignored.

type Command

type Command struct {
	Type uint16
	Data string
}

Command is a wrapper for a queue command and any accompanying data.

type Message

type Message struct {
	Type    Type
	Payload Payload
}

Message is a wrapper for an outgoing websocket message and its message type.

func NewMessage

func NewMessage(wstype Type, instructionCode B2Code, payload string) Message

NewMessage creates and returns new message.

func NewMessageFromPayload

func NewMessageFromPayload(wstype Type, payload Payload) Message

NewMessageFromPayload creates and returns new message, with the specified payload.

func (Message) GetPayloadBytes

func (r Message) GetPayloadBytes() []byte

GetPayloadBytes returns the payload of the message as a byte array.

type Payload

type Payload struct {
	Code    B2Code `json:"code"`
	Message string `json:"message"`
}

Payload is a wrapper for the payload of a websocket message.

func NewPayloadFromBytes

func NewPayloadFromBytes(payloadBytes []byte) Payload

NewPayloadFromBytes tries to create a Payload from the bytes of a websocket message. Errors are silent, and will result in a default payload struct being returned.

type Type

type Type uint16

Type is a type definition for websocket message types.

Jump to

Keyboard shortcuts

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