Documentation ¶
Index ¶
- Constants
- Variables
- func AddChannel(c Channel)
- func ChannelExists(ch string) bool
- func GenerateGUID() string
- func RandString(n int) string
- func RegisterHandler(f interface{})
- func RegisterHandlers(handlers ...interface{})
- func RemoveChannel(name string)
- func SaveSession(sess Session)
- func SendMessageToChannel(m *packets.BanchoSendMessage)
- func Start()
- type Channel
- type Session
- func (s Session) Dispose()
- func (s Session) Handle(pks []packets.Packet)
- func (s Session) In(stream string) bool
- func (s Session) Permissions() int32
- func (s Session) Send(ps ...packets.Packet)
- func (s Session) SendBytes(b []byte)
- func (s Session) SendUsers()
- func (s Session) Subscribe(stream string) bool
- func (s Session) SubscribeChannel(ch string)
- func (s Session) ToHandleUserUpdate() *packets.BanchoHandleUserUpdate
- func (s Session) ToUserPresence() *packets.BanchoUserPresence
- func (s Session) Unsubscribe(stream string)
- func (s Session) UnsubscribeChannel(ch string)
- type SessionCollection
- func (s SessionCollection) Add(sess Session)
- func (s SessionCollection) AllTokens() []string
- func (s SessionCollection) AllUserIDs() []int32
- func (s SessionCollection) Delete(sess Session)
- func (s SessionCollection) Destroy()
- func (s SessionCollection) Len() int
- func (s SessionCollection) Send(ps ...packets.Packet)
- func (s SessionCollection) SendExcept(except []int32, ps ...packets.Packet)
- func (s SessionCollection) TokenFromID(u int32) string
- func (s SessionCollection) TokenFromUsername(u string) string
Constants ¶
const ProtocolVersion = 19
ProtocolVersion is the version of the Bancho protocol.
Variables ¶
var AdminPassword string
AdminPassword is md5 hash of the password.
var Redis *redis.Client
Redis client that will be used to fetch and retrieve information
var Sessions = SessionCollection("")
Sessions is a slice containing all the sessions of the online users.
Functions ¶
func AddChannel ¶
func AddChannel(c Channel)
AddChannel initialises a channel, creating it on redis.
func ChannelExists ¶
ChannelExists checks whether a channel exists
func RegisterHandler ¶
func RegisterHandler(f interface{})
RegisterHandler registers a handler function.
Handler functions are simply in the signature func (p *packets.<something>).
func RegisterHandlers ¶
func RegisterHandlers(handlers ...interface{})
RegisterHandlers simply executes RegisterHandler for many handlers.
func SaveSession ¶
func SaveSession(sess Session)
SaveSession saves the session currently being handled.
func SendMessageToChannel ¶
func SendMessageToChannel(m *packets.BanchoSendMessage)
SendMessageToChannel broadcasts a BanchoSendMessage to all the members of a channel.
Types ¶
type Channel ¶
A Channel is a group of users that can chat together.
func (Channel) ToChannelAvailable ¶
func (c Channel) ToChannelAvailable() *packets.BanchoChannelAvailable
ToChannelAvailable converts a Channel to a BanchoChannelAvailable
type Session ¶
type Session struct { Username string UserID int32 Token string Admin bool LastSeen time.Time State packets.OsuSendUserState Spectating string }
Session is an user's session on Bancho.
func Authenticate ¶
Authenticate logs in into lan.
func GetSession ¶
GetSession retrieves a Session by knowing its token.
func LogoutTokenNotFound ¶
func LogoutTokenNotFound() Session
LogoutTokenNotFound returns a Session for attempts to connect when there's no such user stored with such token.
func NewSession ¶
NewSession creates a new session.
func (Session) Dispose ¶
func (s Session) Dispose()
Dispose finalizes the session removing all references to it (including Sessions) and setting s.disposed to true.
func (Session) Permissions ¶
Permissions converts the bool Admin to osu!'s permissions.
func (Session) SendBytes ¶
SendBytes sends bytes to the session to be send to the client. These are usually packetified packets.
func (Session) SendUsers ¶
func (s Session) SendUsers()
SendUsers sends to this session all the online users.
func (Session) SubscribeChannel ¶
SubscribeChannel subscribes the user to a channel.
func (Session) ToHandleUserUpdate ¶
func (s Session) ToHandleUserUpdate() *packets.BanchoHandleUserUpdate
ToHandleUserUpdate converts a session to a packets.BanchoHandleUserUpdate
func (Session) ToUserPresence ¶
func (s Session) ToUserPresence() *packets.BanchoUserPresence
ToUserPresence converts a session to a packets.BanchoUserPresence
func (Session) Unsubscribe ¶
Unsubscribe removes the user from a stream.
func (Session) UnsubscribeChannel ¶
UnsubscribeChannel unsubscribes the user from a channel.
type SessionCollection ¶
type SessionCollection string
SessionCollection is simply a string, and it mainly indicates a redis list of tokens.
func (SessionCollection) Add ¶
func (s SessionCollection) Add(sess Session)
Add adds a Session to the collection.
func (SessionCollection) AllTokens ¶
func (s SessionCollection) AllTokens() []string
AllTokens retrieves all the tokens in the session collection.
func (SessionCollection) AllUserIDs ¶
func (s SessionCollection) AllUserIDs() []int32
AllUserIDs fetches all the user IDs in the SessionCollection.
func (SessionCollection) Delete ¶
func (s SessionCollection) Delete(sess Session)
Delete removes a Session from the collection.
func (SessionCollection) Destroy ¶
func (s SessionCollection) Destroy()
Destroy removes from redis all references to this SessionCollection.
func (SessionCollection) Len ¶
func (s SessionCollection) Len() int
Len returns the length of the SessionCollection's slice.
func (SessionCollection) Send ¶
func (s SessionCollection) Send(ps ...packets.Packet)
Send sends packets to all members of the SessionCollection
func (SessionCollection) SendExcept ¶
func (s SessionCollection) SendExcept(except []int32, ps ...packets.Packet)
SendExcept sends packets to all members of the SessionCollection, except for those with the ID specified.
func (SessionCollection) TokenFromID ¶
func (s SessionCollection) TokenFromID(u int32) string
TokenFromID retrieves a Session by its user's ID.
func (SessionCollection) TokenFromUsername ¶
func (s SessionCollection) TokenFromUsername(u string) string
TokenFromUsername retrieves a token of a session using its user's username.