packethandler

package
v0.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2016 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TypeLogin = iota
	TypePoll
	TypeChatMessage
)

Request types

Variables

View Source
var Sessions map[string]*Session

Sessions is a map of connections to the server via the bancho protocol.

Functions

func Broadcast

func Broadcast(p packets.Packet, except string)

Broadcast writes a packets to every user, except the one specified in "except".

func GenerateGUID

func GenerateGUID() string

GenerateGUID makes a random GUID.

func GetUserFriends

func GetUserFriends(userID int) []int32

GetUserFriends returns an int32 array containing all the friends of an user, be them online or not.

func GetUserIDs

func GetUserIDs() []int32

GetUserIDs retrieves all the online users' IDs.

func Handle

func Handle(input []byte, output *[]byte, token string) (string, error)

Handle takes an input and writes data to an output. Not very hard.

func Login

func Login(l logindata.LoginData, output *[]byte) (string, error)

Login logs the user into bancho. Returns the osu! token and any eventual error.

func NewPacketHandler

func NewPacketHandler(pack inbound.BasePacket, s *Session)

NewPacketHandler handles inbound packets, and sends them to be analysed by functions, or if it's short by a case itself.

func Prune

func Prune()

Prune deletes sessions which haven't been accessed for more than 150 seconds. Prune is run every 10 seconds.

func SetUp

func SetUp()

SetUp is needed to make things work and should always be called unless you have a very good fucking reason for not doing it.

Types

type Session

type Session struct {
	User        User
	LastRequest time.Time
	Terminated  bool
	// contains filtered or unexported fields
}

Session is an alive connection of a logged in user.

func NewSession

func NewSession(u User) (*Session, string)

NewSession generates a new session.

func (Session) Push

func (s Session) Push(val ...packets.Packet)

Push appends an element to the current session.

type User

type User struct {
	ID        int32
	Name      string
	Token     string
	UTCOffset byte
	Country   byte
	Colour    byte
	Position  struct {
		Longitude float32
		Latitude  float32
	}
	Rank     int
	Username string
	Status   common.Status
}

User represents an user online on bancho.

func (User) ToUserDataInfo

func (u User) ToUserDataInfo() packets.UserDataInfo

ToUserDataINfo converts a packethandler.User to a packets.UserDataInfo.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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