packet

package
v0.0.0-...-b3031ee Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: MIT Imports: 11 Imported by: 0

README

packet

This is where we keep all of the packets that can be sent in Playground! Our packets generally fall into two classes (and they can belong to both):

  • client: A packet sent by clients to the server
    • e.g. get_messages will be sent by a client who needs to load their private messages with someone else
  • server: A packet sent by the server to clients
    • e.g. messages will be returned to a client after they send a get_messages packet

One example of a packet that belongs to both classes is chat, which a client can send to the server in order to send a chat message to the room. The server will in turn send this same packet back to the other clients.

Adding a new client packet

  1. Create a struct for this packet (see existing files for examples). Make sure to implement PermissionCheck, MarshalBinary, and UnmarshalBinary.
    • PermissionCheck returns true when the sender has permission to send that packet
  2. Add the new packet to parse.go along with its identifier
  3. Write the handler for this packet in hub.go

Adding a new server packet

  1. Create a struct for this packet. Make sure to implement MarshalBinary and UnmarshalBinary
  2. Create an Init function with parameters that mirror what needs to be sent to the client
  3. Use the Init function to create a new packet, and pass it to h.Send to send it to clients

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AchievementsPacket

type AchievementsPacket struct {
	BasePacket
	Packet              `json:",omitempty"`
	models.Achievements `json:"achievements"`

	// The id of the client who we're getting achievements for
	ID string `json:"id"`
}

func NewAchievementsPacket

func NewAchievementsPacket(characterID string) *AchievementsPacket

func (AchievementsPacket) MarshalBinary

func (p AchievementsPacket) MarshalBinary() ([]byte, error)

func (AchievementsPacket) UnmarshalBinary

func (p AchievementsPacket) UnmarshalBinary(data []byte) error

type AddEmailPacket

type AddEmailPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The email address to check and send the code to
	Email string `json:"email"`

	// The role this user is signing up for (see models.Role)
	Role int `json:"role"`

	// The id of the sponsor, if Role == SponsorRep
	SponsorID string `json:"sponsorId"`
}

Sent by clients when they need to add a valid email to our system

func (AddEmailPacket) MarshalBinary

func (p AddEmailPacket) MarshalBinary() ([]byte, error)

func (AddEmailPacket) PermissionCheck

func (p AddEmailPacket) PermissionCheck(characterID string, role models.Role) bool

func (AddEmailPacket) UnmarshalBinary

func (p AddEmailPacket) UnmarshalBinary(data []byte) error

type BasePacket

type BasePacket struct {
	Packet

	// Identifies the type of packet
	Type string `json:"type"`
}

The base packet that can be sent between clients and server. These are all of the required attributes of any packet

func (*BasePacket) PermissionCheck

func (p *BasePacket) PermissionCheck(characterID string, role models.Role) bool

type ChatPacket

type ChatPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The message being sent
	Message string `json:"mssg"`

	// The id of the client who's joining
	ID string `json:"id"`

	// The client's room
	Room string `json:"room"`
}

func (ChatPacket) MarshalBinary

func (p ChatPacket) MarshalBinary() ([]byte, error)

func (ChatPacket) PermissionCheck

func (p ChatPacket) PermissionCheck(characterID string, role models.Role) bool

func (ChatPacket) UnmarshalBinary

func (p ChatPacket) UnmarshalBinary(data []byte) error

type DancePacket

type DancePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The id of the client who is dancing
	ID string `json:"id"`

	// The room that the client is dancing in
	Room string `json:"room"`

	// The client's new x position (0-1)
	Dance int `json:"dance"`
}

Sent by clients when they dance

func (DancePacket) MarshalBinary

func (p DancePacket) MarshalBinary() ([]byte, error)

func (DancePacket) PermissionCheck

func (p DancePacket) PermissionCheck(characterID string, role models.Role) bool

func (DancePacket) UnmarshalBinary

func (p DancePacket) UnmarshalBinary(data []byte) error

type ElementAddPacket

type ElementAddPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The room being updated
	Room string `json:"room"`

	// The ID of the element being updated
	ID string `json:"id"`

	// The new element
	Element models.Element `json:"element"`
}

Sent by clients when they're adding an element

func (ElementAddPacket) MarshalBinary

func (p ElementAddPacket) MarshalBinary() ([]byte, error)

func (ElementAddPacket) PermissionCheck

func (p ElementAddPacket) PermissionCheck(characterID string, role models.Role) bool

func (ElementAddPacket) UnmarshalBinary

func (p ElementAddPacket) UnmarshalBinary(data []byte) error

type ElementDeletePacket

type ElementDeletePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The room being updated
	Room string `json:"room"`

	// The ID of the element being deleted
	ID string `json:"id"`
}

Sent by clients when they're deleting an element

func (ElementDeletePacket) MarshalBinary

func (p ElementDeletePacket) MarshalBinary() ([]byte, error)

func (ElementDeletePacket) PermissionCheck

func (p ElementDeletePacket) PermissionCheck(characterID string, role models.Role) bool

func (ElementDeletePacket) UnmarshalBinary

func (p ElementDeletePacket) UnmarshalBinary(data []byte) error

type ElementTogglePacket

type ElementTogglePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The ID of the element being toggled
	ID string `json:"id"`
}

Sent by clients when they're deleting an element

func (ElementTogglePacket) MarshalBinary

func (p ElementTogglePacket) MarshalBinary() ([]byte, error)

func (ElementTogglePacket) PermissionCheck

func (p ElementTogglePacket) PermissionCheck(characterID string, role models.Role) bool

func (ElementTogglePacket) UnmarshalBinary

func (p ElementTogglePacket) UnmarshalBinary(data []byte) error

type ElementUpdatePacket

type ElementUpdatePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The room being updated
	Room string `json:"room"`

	// The ID of the element being updated
	ID string `json:"id"`

	// The new element
	Element models.Element `json:"element"`
}

Sent by clients when they're updating the room

func NewElementUpdatePacket

func NewElementUpdatePacket(room, id string, element models.Element) *ElementUpdatePacket

func (ElementUpdatePacket) MarshalBinary

func (p ElementUpdatePacket) MarshalBinary() ([]byte, error)

func (ElementUpdatePacket) PermissionCheck

func (p ElementUpdatePacket) PermissionCheck(characterID string, role models.Role) bool

func (ElementUpdatePacket) UnmarshalBinary

func (p ElementUpdatePacket) UnmarshalBinary(data []byte) error

type EmailCodePacket

type EmailCodePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The email address to check and send the code to
	Email string `json:"email"`

	// The role this user is signing up for (see models.Role)
	Role int `json:"role"`
}

Sent by clients when they need a login code

func (EmailCodePacket) MarshalBinary

func (p EmailCodePacket) MarshalBinary() ([]byte, error)

func (EmailCodePacket) PermissionCheck

func (p EmailCodePacket) PermissionCheck(characterID string, role models.Role) bool

func (EmailCodePacket) UnmarshalBinary

func (p EmailCodePacket) UnmarshalBinary(data []byte) error

type ErrorPacket

type ErrorPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Code int `json:"code"`
}

func NewErrorPacket

func NewErrorPacket(code int) *ErrorPacket

func (ErrorPacket) MarshalBinary

func (p ErrorPacket) MarshalBinary() ([]byte, error)

func (ErrorPacket) UnmarshalBinary

func (p ErrorPacket) UnmarshalBinary(data []byte) error

type EventPacket

type EventPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// ID of this event
	ID string `json:"id"`
}

Sent when a user confirms attendance for an event

func (*EventPacket) Init

func (p *EventPacket) Init(id string) *EventPacket

func (EventPacket) MarshalBinary

func (p EventPacket) MarshalBinary() ([]byte, error)

func (EventPacket) PermissionCheck

func (p EventPacket) PermissionCheck(characterID string, role models.Role) bool

func (EventPacket) UnmarshalBinary

func (p EventPacket) UnmarshalBinary(data []byte) error

type Friend

type Friend struct {
	ID       string    `json:"id"`
	Name     string    `json:"name"`
	School   string    `json:"school"`
	Status   int       `json:"status"`
	Teammate bool      `json:"teammate"`
	Pending  bool      `json:"pending"`
	LastSeen time.Time `json:"lastSeen"`
}

type FriendRequestPacket

type FriendRequestPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	SenderID    string `json:"senderId"`
	RecipientID string `json:"recipientId"`
}

func (FriendRequestPacket) MarshalBinary

func (p FriendRequestPacket) MarshalBinary() ([]byte, error)

func (FriendRequestPacket) PermissionCheck

func (p FriendRequestPacket) PermissionCheck(characterID string, role models.Role) bool

func (FriendRequestPacket) UnmarshalBinary

func (p FriendRequestPacket) UnmarshalBinary(data []byte) error

type FriendUpdatePacket

type FriendUpdatePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Friend Friend `json:"friend"`

	// Server attributes
	RecipientID string `json:"recipientId"`
}

func NewFriendUpdatePacket

func NewFriendUpdatePacket(characterID string, friendID string) *FriendUpdatePacket

func (FriendUpdatePacket) MarshalBinary

func (p FriendUpdatePacket) MarshalBinary() ([]byte, error)

func (FriendUpdatePacket) PermissionCheck

func (p FriendUpdatePacket) PermissionCheck(characterID string, role models.Role) bool

This isn't needed -- remove later

func (FriendUpdatePacket) UnmarshalBinary

func (p FriendUpdatePacket) UnmarshalBinary(data []byte) error

type GetAchievementsPacket

type GetAchievementsPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	ID string `json:"id"`
}

func (GetAchievementsPacket) MarshalBinary

func (p GetAchievementsPacket) MarshalBinary() ([]byte, error)

func (GetAchievementsPacket) PermissionCheck

func (p GetAchievementsPacket) PermissionCheck(characterID string, role models.Role) bool

func (GetAchievementsPacket) UnmarshalBinary

func (p GetAchievementsPacket) UnmarshalBinary(data []byte) error

type GetCurrentSongPacket

type GetCurrentSongPacket struct {
	BasePacket
}

func (GetCurrentSongPacket) MarshalBinary

func (p GetCurrentSongPacket) MarshalBinary() ([]byte, error)

func (GetCurrentSongPacket) PermissionCheck

func (p GetCurrentSongPacket) PermissionCheck(characterID string, role models.Role) bool

func (GetCurrentSongPacket) UnmarshalBinary

func (p GetCurrentSongPacket) UnmarshalBinary(data []byte) error

type GetMapPacket

type GetMapPacket struct {
	BasePacket
}

func (GetMapPacket) PermissionCheck

func (p GetMapPacket) PermissionCheck(characterID string, role models.Role) bool

type GetMessagesPacket

type GetMessagesPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Recipient string `json:"recipient"`
}

func (GetMessagesPacket) MarshalBinary

func (p GetMessagesPacket) MarshalBinary() ([]byte, error)

func (GetMessagesPacket) PermissionCheck

func (p GetMessagesPacket) PermissionCheck(characterID string, role models.Role) bool

func (GetMessagesPacket) UnmarshalBinary

func (p GetMessagesPacket) UnmarshalBinary(data []byte) error

type GetSongsPacket

type GetSongsPacket struct {
	BasePacket
}

func (GetSongsPacket) MarshalBinary

func (p GetSongsPacket) MarshalBinary() ([]byte, error)

func (GetSongsPacket) PermissionCheck

func (p GetSongsPacket) PermissionCheck(characterID string, role models.Role) bool

func (GetSongsPacket) UnmarshalBinary

func (p GetSongsPacket) UnmarshalBinary(data []byte) error

type GetSponsorPacket

type GetSponsorPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	SponsorID string `json:"id"`
}

func (GetSponsorPacket) MarshalBinary

func (p GetSponsorPacket) MarshalBinary() ([]byte, error)

func (GetSponsorPacket) PermissionCheck

func (p GetSponsorPacket) PermissionCheck(characterID string, role models.Role) bool

func (GetSponsorPacket) UnmarshalBinary

func (p GetSponsorPacket) UnmarshalBinary(data []byte) error

type HallwayAddPacket

type HallwayAddPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The room being updated
	Room string `json:"room"`

	// The ID of the hallway being updated
	ID string `json:"id"`

	// The new hallway
	Hallway models.Hallway `json:"hallway"`
}

Sent by clients when adding a hallway

func (HallwayAddPacket) MarshalBinary

func (p HallwayAddPacket) MarshalBinary() ([]byte, error)

func (HallwayAddPacket) PermissionCheck

func (p HallwayAddPacket) PermissionCheck(characterID string, role models.Role) bool

func (HallwayAddPacket) UnmarshalBinary

func (p HallwayAddPacket) UnmarshalBinary(data []byte) error

type HallwayDeletePacket

type HallwayDeletePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The room being updated
	Room string `json:"room"`

	// The ID of the hallway being deleted
	ID string `json:"id"`
}

Sent by clients when they're deleting a hallway

func (HallwayDeletePacket) MarshalBinary

func (p HallwayDeletePacket) MarshalBinary() ([]byte, error)

func (HallwayDeletePacket) PermissionCheck

func (p HallwayDeletePacket) PermissionCheck(characterID string, role models.Role) bool

func (HallwayDeletePacket) UnmarshalBinary

func (p HallwayDeletePacket) UnmarshalBinary(data []byte) error

type HallwayUpdatePacket

type HallwayUpdatePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The room being updated
	Room string `json:"room"`

	// The ID of the hallway being updated
	ID string `json:"id"`

	// The updated hallway
	Hallway models.Hallway `json:"hallway"`
}

Sent by clients when they're updating a hallway

func (HallwayUpdatePacket) MarshalBinary

func (p HallwayUpdatePacket) MarshalBinary() ([]byte, error)

func (HallwayUpdatePacket) PermissionCheck

func (p HallwayUpdatePacket) PermissionCheck(characterID string, role models.Role) bool

func (HallwayUpdatePacket) UnmarshalBinary

func (p HallwayUpdatePacket) UnmarshalBinary(data []byte) error

type InitPacket

type InitPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Character *models.Character `json:"character"`

	// The room that the client is about to join
	Room *models.Room `json:"room"`

	// A token for the client to save for future authentication
	Token string `json:"token,omitempty"`

	// All possible element names
	ElementNames []string `json:"elementNames"`

	// All room names
	RoomNames []string `json:"roomNames"`

	// All of this user's friends
	Friends []Friend `json:"friends"`

	// All of the events happening throughout the weekend
	Events []*models.Event `json:"events"`

	// Projects of the users in this room, if we're in the hacking arena
	Projects []*models.Project `json:"projects"`

	// Settings
	Settings *models.Settings `json:"settings"`

	// True if the feedback window should open
	OpenFeedback bool `json:"openFeedback"`

	// True if the user needs to register
	FirstTime bool `json:"firstTime"`
}

Sent by server to clients upon connecting. Contains information about the world that they load into

func NewInitPacket

func NewInitPacket(characterID, roomID string, needsToken bool) *InitPacket

func (InitPacket) MarshalBinary

func (p InitPacket) MarshalBinary() ([]byte, error)

func (InitPacket) UnmarshalBinary

func (p InitPacket) UnmarshalBinary(data []byte) error

type JoinPacket

type JoinPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// Client attributes
	Name       string `json:"name,omitempty"`
	QuillToken string `json:"quillToken,omitempty"`
	Token      string `json:"token,omitempty"`

	Email string `json:"email,omitempty"`
	Code  int    `json:"code,omitempty"`

	// Server attributes
	Character *models.Character `json:"character"`
	ClientID  string            `json:"clientId,omitempty"`
	Project   *models.Project   `json:"project"`
	Room      string            `json:"room"`
}

Sent by clients after receiving the init packet. Identifies them to the server, and in turn other clients

func NewJoinPacket

func NewJoinPacket(character *models.Character, room string) *JoinPacket

func (JoinPacket) MarshalBinary

func (p JoinPacket) MarshalBinary() ([]byte, error)

func (JoinPacket) PermissionCheck

func (p JoinPacket) PermissionCheck(characterID string, role models.Role) bool

func (*JoinPacket) SetProject

func (p *JoinPacket) SetProject()

func (JoinPacket) UnmarshalBinary

func (p JoinPacket) UnmarshalBinary(data []byte) error

type JukeboxWarningPacket

type JukeboxWarningPacket struct {
	BasePacket
	Packet `json:",omitempty"`
}

Sent by ingests when a user opens the jukebox for the first time

func NewJukeboxWarningPacket

func NewJukeboxWarningPacket() *JukeboxWarningPacket

func (*JukeboxWarningPacket) Init

func (JukeboxWarningPacket) MarshalBinary

func (p JukeboxWarningPacket) MarshalBinary() ([]byte, error)

func (JukeboxWarningPacket) PermissionCheck

func (p JukeboxWarningPacket) PermissionCheck(characterID string, role models.Role) bool

func (JukeboxWarningPacket) UnmarshalBinary

func (p JukeboxWarningPacket) UnmarshalBinary(data []byte) error

type LeavePacket

type LeavePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The character who is leaving
	Character *models.Character `json:"character"`

	// The room that the client is leaving
	Room string `json:"room"`
}

Sent by ingests when a client disconnects

func NewLeavePacket

func NewLeavePacket(character *models.Character, room string) *LeavePacket

func (LeavePacket) MarshalBinary

func (p LeavePacket) MarshalBinary() ([]byte, error)

func (LeavePacket) PermissionCheck

func (p LeavePacket) PermissionCheck(characterID string, role models.Role) bool

func (LeavePacket) UnmarshalBinary

func (p LeavePacket) UnmarshalBinary(data []byte) error

type MapPacket

type MapPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Locations []*models.Location `json:"locations"`
}

func NewMapPacket

func NewMapPacket() *MapPacket

func (MapPacket) MarshalBinary

func (p MapPacket) MarshalBinary() ([]byte, error)

func (MapPacket) UnmarshalBinary

func (p MapPacket) UnmarshalBinary(data []byte) error

type MessagePacket

type MessagePacket struct {
	BasePacket
	Packet `json:",omitempty"`
	*models.Message
}

func (MessagePacket) MarshalBinary

func (p MessagePacket) MarshalBinary() ([]byte, error)

func (MessagePacket) PermissionCheck

func (p MessagePacket) PermissionCheck(characterID string, role models.Role) bool

func (MessagePacket) UnmarshalBinary

func (p MessagePacket) UnmarshalBinary(data []byte) error

type MessagesPacket

type MessagesPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Messages  []*models.Message `json:"messages"`
	Recipient string            `json:"recipient"`
}

func NewMessagesPacket

func NewMessagesPacket(messages []*models.Message, recipient string) *MessagesPacket

func (MessagesPacket) MarshalBinary

func (p MessagesPacket) MarshalBinary() ([]byte, error)

func (MessagesPacket) UnmarshalBinary

func (p MessagesPacket) UnmarshalBinary(data []byte) error

type MovePacket

type MovePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The id of the client who is moving
	ID string `json:"id"`

	// The room that the client is moving in
	Room string `json:"room"`

	// The client's new x position (0-1)
	X float64 `json:"x"`

	// The client's new y position (0-1)
	Y float64 `json:"y"`
}

Sent by clients when they move around

func NewMovePacket

func NewMovePacket(id, room string, x, y float64) *MovePacket

func (MovePacket) MarshalBinary

func (p MovePacket) MarshalBinary() ([]byte, error)

func (MovePacket) PermissionCheck

func (p MovePacket) PermissionCheck(characterID string, role models.Role) bool

func (MovePacket) UnmarshalBinary

func (p MovePacket) UnmarshalBinary(data []byte) error

type NotificationLevel

type NotificationLevel int
const (
	// Low-level/info notification -- we'll only display the notification pop-up in Hack Penguin
	Low NotificationLevel = iota

	// Medium-level notification -- we'll also contact them through their preferred methods of notification
	Medium

	// Urgent notification -- we will reach out through every method we have available
	High
)

type NotificationPacket

type NotificationPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	NotificationType NotificationType       `json:"notificationType"`
	Data             map[string]interface{} `json:"data"`
	Level            NotificationLevel      `json:"level"`
}

func NewAchievementNotificationPacket

func NewAchievementNotificationPacket(id string) *NotificationPacket

func NewMessageNotificationPacket

func NewMessageNotificationPacket(text string) *NotificationPacket

func (NotificationPacket) MarshalBinary

func (p NotificationPacket) MarshalBinary() ([]byte, error)

func (NotificationPacket) UnmarshalBinary

func (p NotificationPacket) UnmarshalBinary(data []byte) error

type NotificationType

type NotificationType string
const (
	Achievement NotificationType = "achievement"
	Message                      = "message"
)

type Packet

type Packet interface {
	PermissionCheck(characterID string, role models.Role) bool
}

func ParsePacket

func ParsePacket(data []byte) (Packet, error)

type PlaySongPacket

type PlaySongPacket struct {
	BasePacket
	Packet `json:",omitempty"`
	Song   *models.Song `json:"song"`
	Start  int          `json:"start"`
	End    int          `json:"end"`
}

Sent by ingests when a song is added to queue

func NewPlaySongPacket

func NewPlaySongPacket(song *models.Song, start int) *PlaySongPacket

func (*PlaySongPacket) Init

func (p *PlaySongPacket) Init(song *models.Song) *PlaySongPacket

func (PlaySongPacket) MarshalBinary

func (p PlaySongPacket) MarshalBinary() ([]byte, error)

func (PlaySongPacket) PermissionCheck

func (p PlaySongPacket) PermissionCheck(characterID string, role models.Role) bool

func (PlaySongPacket) UnmarshalBinary

func (p PlaySongPacket) UnmarshalBinary(data []byte) error

type ProjectFormPacket

type ProjectFormPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Challenges []string `json:"challenges"`
	Teammates  []string `json:"teammates"`
	*models.Project
}

func (ProjectFormPacket) MarshalBinary

func (p ProjectFormPacket) MarshalBinary() ([]byte, error)

func (ProjectFormPacket) PermissionCheck

func (p ProjectFormPacket) PermissionCheck(characterID string, role models.Role) bool

func (ProjectFormPacket) UnmarshalBinary

func (p ProjectFormPacket) UnmarshalBinary(data []byte) error

type QueueJoinPacket

type QueueJoinPacket struct {
	BasePacket

	SponsorID string   `json:"sponsorId"`
	Interests []string `json:"interests"`
}

Sent by hackers to join a sponsor's queue

func (QueueJoinPacket) MarshalBinary

func (p QueueJoinPacket) MarshalBinary() ([]byte, error)

func (QueueJoinPacket) PermissionCheck

func (p QueueJoinPacket) PermissionCheck(characterID string, role models.Role) bool

func (QueueJoinPacket) UnmarshalBinary

func (p QueueJoinPacket) UnmarshalBinary(data []byte) error

type QueueRemovePacket

type QueueRemovePacket struct {
	BasePacket

	SponsorID   string `json:"sponsorId"`
	CharacterID string `json:"characterId"`
	Zoom        string `json:"zoom"`
}

Sent by hackers to take themselves off queue

func (QueueRemovePacket) MarshalBinary

func (p QueueRemovePacket) MarshalBinary() ([]byte, error)

func (QueueRemovePacket) PermissionCheck

func (p QueueRemovePacket) PermissionCheck(characterID string, role models.Role) bool

func (QueueRemovePacket) UnmarshalBinary

func (p QueueRemovePacket) UnmarshalBinary(data []byte) error

type QueueSubscribePacket

type QueueSubscribePacket struct {
	BasePacket

	SponsorID string `json:"sponsorId"`

	Characters []*models.Character `json:"characters"`
}

sent by hackers and sponsors to subscribe to queue updates

func (QueueSubscribePacket) MarshalBinary

func (p QueueSubscribePacket) MarshalBinary() ([]byte, error)

func (QueueSubscribePacket) PermissionCheck

func (p QueueSubscribePacket) PermissionCheck(characterID string, role models.Role) bool

func (QueueSubscribePacket) UnmarshalBinary

func (p QueueSubscribePacket) UnmarshalBinary(data []byte) error

type QueueUnsubscribePacket

type QueueUnsubscribePacket struct {
	BasePacket

	SponsorID string `json:"sponsorId"`
}

sent by hackers and sponsors to unsubscribe to queue updates

func (QueueUnsubscribePacket) MarshalBinary

func (p QueueUnsubscribePacket) MarshalBinary() ([]byte, error)

func (QueueUnsubscribePacket) PermissionCheck

func (p QueueUnsubscribePacket) PermissionCheck(characterID string, role models.Role) bool

func (QueueUnsubscribePacket) UnmarshalBinary

func (p QueueUnsubscribePacket) UnmarshalBinary(data []byte) error

type QueueUpdateHackerPacket

type QueueUpdateHackerPacket struct {
	BasePacket

	SponsorID string `json:"sponsorId"`
	Position  int    `json:"position"`
	URL       string `json:"url,omitempty"`

	// Server attributes
	CharacterIDs []string `json:"characterIds"`
}

Sent by server to update a hacker on their position in the queue

func NewQueueUpdateHackerPacket

func NewQueueUpdateHackerPacket(sponsorID string, position int, url string) *QueueUpdateHackerPacket

func (QueueUpdateHackerPacket) MarshalBinary

func (p QueueUpdateHackerPacket) MarshalBinary() ([]byte, error)

func (QueueUpdateHackerPacket) PermissionCheck

func (p QueueUpdateHackerPacket) PermissionCheck(characterID string, role models.Role) bool

This isn't needed -- remove later

func (QueueUpdateHackerPacket) UnmarshalBinary

func (p QueueUpdateHackerPacket) UnmarshalBinary(data []byte) error

type QueueUpdateSponsorPacket

type QueueUpdateSponsorPacket struct {
	BasePacket

	Subscribers []*models.QueueSubscriber `json:"subscribers"`

	// Server attributes
	CharacterIDs []string `json:"characterIds"`
}

Sent by server to update a hacker on their position in the queue

func NewQueueUpdateSponsorPacket

func NewQueueUpdateSponsorPacket(subscribers []*models.QueueSubscriber) *QueueUpdateSponsorPacket

func (QueueUpdateSponsorPacket) MarshalBinary

func (p QueueUpdateSponsorPacket) MarshalBinary() ([]byte, error)

func (QueueUpdateSponsorPacket) PermissionCheck

func (p QueueUpdateSponsorPacket) PermissionCheck(characterID string, role models.Role) bool

This isn't needed -- remove later

func (QueueUpdateSponsorPacket) UnmarshalBinary

func (p QueueUpdateSponsorPacket) UnmarshalBinary(data []byte) error

type RegisterPacket

type RegisterPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Name                string                `json:"name"`
	Location            string                `json:"location"`
	Bio                 string                `json:"bio"`
	PhoneNumber         string                `json:"phoneNumber"`
	BrowserSubscription *webpush.Subscription `json:"browserSubscription"`
}

func (RegisterPacket) MarshalBinary

func (p RegisterPacket) MarshalBinary() ([]byte, error)

func (RegisterPacket) PermissionCheck

func (p RegisterPacket) PermissionCheck(characterID string, role models.Role) bool

func (RegisterPacket) UnmarshalBinary

func (p RegisterPacket) UnmarshalBinary(data []byte) error

type ReportPacket

type ReportPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	CharacterID string `json:"characterId"`
	Text        string `json:"text"`
}

func (ReportPacket) MarshalBinary

func (p ReportPacket) MarshalBinary() ([]byte, error)

func (ReportPacket) PermissionCheck

func (p ReportPacket) PermissionCheck(characterID string, role models.Role) bool

func (ReportPacket) UnmarshalBinary

func (p ReportPacket) UnmarshalBinary(data []byte) error

type RoomAddPacket

type RoomAddPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The name of the new room
	ID string `json:"id"`

	// The background path for this room
	Background string `json:"background"`

	// True if this is a sponsor room
	Sponsor bool `json:"sponsor"`
}

Sent by clients when they're adding an element

func (RoomAddPacket) MarshalBinary

func (p RoomAddPacket) MarshalBinary() ([]byte, error)

func (RoomAddPacket) PermissionCheck

func (p RoomAddPacket) PermissionCheck(characterID string, role models.Role) bool

func (RoomAddPacket) UnmarshalBinary

func (p RoomAddPacket) UnmarshalBinary(data []byte) error

type SettingsPacket

type SettingsPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The client's new settings
	Settings *models.Settings `json:"settings"`

	CheckTwitter bool `json:"checkTwitter"`

	Location string `json:"location"`
	Bio      string `json:"bio"`
	Zoom     string `json:"zoom"`
}

Sent by clients when settings are changed

func (SettingsPacket) MarshalBinary

func (p SettingsPacket) MarshalBinary() ([]byte, error)

func (SettingsPacket) PermissionCheck

func (p SettingsPacket) PermissionCheck(characterID string, role models.Role) bool

func (SettingsPacket) UnmarshalBinary

func (p SettingsPacket) UnmarshalBinary(data []byte) error

type SongPacket

type SongPacket struct {
	BasePacket
	Packet `json:",omitempty"`
	*models.Song
	RequiresWarning bool `json:"requiresWarning"`
	Remove          bool `json:"remove"`
}

Sent by ingests when a song is added to queue

func (*SongPacket) Init

func (p *SongPacket) Init(song *models.Song) *SongPacket

func (SongPacket) MarshalBinary

func (p SongPacket) MarshalBinary() ([]byte, error)

func (SongPacket) PermissionCheck

func (p SongPacket) PermissionCheck(characterID string, role models.Role) bool

func (SongPacket) UnmarshalBinary

func (p SongPacket) UnmarshalBinary(data []byte) error

type SongsPacket

type SongsPacket struct {
	BasePacket

	Songs []*models.Song `json:"songs"`
}

func NewSongsPacket

func NewSongsPacket(songs []*models.Song) *SongsPacket

func (SongsPacket) MarshalBinary

func (p SongsPacket) MarshalBinary() ([]byte, error)

func (SongsPacket) UnmarshalBinary

func (p SongsPacket) UnmarshalBinary(data []byte) error

type SponsorPacket

type SponsorPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	Sponsor *models.Sponsor `json:"sponsor"`
}

func NewSponsorPacket

func NewSponsorPacket(sponsorID string) *SponsorPacket

func (SponsorPacket) MarshalBinary

func (p SponsorPacket) MarshalBinary() ([]byte, error)

func (SponsorPacket) UnmarshalBinary

func (p SponsorPacket) UnmarshalBinary(data []byte) error

type StatusPacket

type StatusPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// True if the user is online and has the tab open -- false if the window doesn't have focus
	Active bool `json:"active"`

	// True if the user has the tab open, regardless of focus
	Online bool `json:"online"`

	// The ID of the character who this is a status update for
	ID string `json:"id"`

	// Server attributes
	FriendIDs   []string `json:"friendIds"`
	TeammateIDs []string `json:"teammateIds"`
}

Sent by clients when the window gains or loses focus

func NewStatusPacket

func NewStatusPacket(characterID string, online bool) *StatusPacket

func (StatusPacket) MarshalBinary

func (p StatusPacket) MarshalBinary() ([]byte, error)

func (StatusPacket) PermissionCheck

func (p StatusPacket) PermissionCheck(characterID string, role models.Role) bool

func (StatusPacket) UnmarshalBinary

func (p StatusPacket) UnmarshalBinary(data []byte) error

type TeleportPacket

type TeleportPacket struct {
	BasePacket
	Packet `json:",omitempty"`

	// The charcater who is teleporting
	Character *models.Character `json:"character"`

	// The room they're moving from
	From string `json:"from"`

	// The room they're moving to
	To string `json:"to"`

	// The resulting X coordinate
	X float64 `json:"x"`

	// The resulting Y coordinate
	Y float64 `json:"y"`
}

Sent by ingests when a client changes rooms

func NewTeleportPacket

func NewTeleportPacket(character *models.Character, from, to string) *TeleportPacket

func (TeleportPacket) MarshalBinary

func (p TeleportPacket) MarshalBinary() ([]byte, error)

func (TeleportPacket) PermissionCheck

func (p TeleportPacket) PermissionCheck(characterID string, role models.Role) bool

func (TeleportPacket) UnmarshalBinary

func (p TeleportPacket) UnmarshalBinary(data []byte) error

type UpdateMapPacket

type UpdateMapPacket struct {
	BasePacket
	Packet           `json:",omitempty"`
	*models.Location `json:"location"`
}

func (UpdateMapPacket) MarshalBinary

func (p UpdateMapPacket) MarshalBinary() ([]byte, error)

func (UpdateMapPacket) PermissionCheck

func (p UpdateMapPacket) PermissionCheck(characterID string, role models.Role) bool

func (UpdateMapPacket) UnmarshalBinary

func (p UpdateMapPacket) UnmarshalBinary(data []byte) error

type UpdateSponsorPacket

type UpdateSponsorPacket struct {
	BasePacket
	Packet `json:",omitempty"`
	*models.Sponsor

	SetQueueOpen bool `json:"setQueueOpen"`
}

func (UpdateSponsorPacket) MarshalBinary

func (p UpdateSponsorPacket) MarshalBinary() ([]byte, error)

func (UpdateSponsorPacket) PermissionCheck

func (p UpdateSponsorPacket) PermissionCheck(characterID string, role models.Role) bool

func (UpdateSponsorPacket) UnmarshalBinary

func (p UpdateSponsorPacket) UnmarshalBinary(data []byte) error

type WardrobeChangePacket

type WardrobeChangePacket struct {
	BasePacket
	Packet `json:",omitempty"`

	CharacterID string `json:"characterId"`
	Room        string `json:"room"`

	EyeColor   string `json:"eyeColor"`
	SkinColor  string `json:"skinColor"`
	ShirtColor string `json:"shirtColor"`
	PantsColor string `json:"pantsColor"`
}

func (WardrobeChangePacket) MarshalBinary

func (p WardrobeChangePacket) MarshalBinary() ([]byte, error)

func (WardrobeChangePacket) PermissionCheck

func (p WardrobeChangePacket) PermissionCheck(characterID string, role models.Role) bool

func (WardrobeChangePacket) UnmarshalBinary

func (p WardrobeChangePacket) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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