server

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: Apache-2.0 Imports: 70 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NOTIFICATION_DM_REQUEST         int32 = -1
	NOTIFICATION_FRIEND_REQUEST     int32 = -2
	NOTIFICATION_FRIEND_ACCEPT      int32 = -3
	NOTIFICATION_GROUP_ADD          int32 = -4
	NOTIFICATION_GROUP_JOIN_REQUEST int32 = -5
	NOTIFICATION_FRIEND_JOIN_GAME   int32 = -6
)
View Source
const (
	LeaderboardSortOrderAscending = iota
	LeaderboardSortOrderDescending
)
View Source
const (
	LeaderboardOperatorBest = iota
	LeaderboardOperatorSet
	LeaderboardOperatorIncrement
)
View Source
const (
	InputQueueSize = 128
	CallQueueSize  = 128
)
View Source
const (
	ChannelMessageTypeChat int32 = iota
	ChannelMessageTypeChatUpdate
	ChannelMessageTypeChatRemove
	ChannelMessageTypeGroupJoin
	ChannelMessageTypeGroupAdd
	ChannelMessageTypeGroupKick
	ChannelMessageTypeGroupPromoted
)
View Source
const (
	StreamModeNotifications uint8 = iota
	StreamModeStatus
	StreamModeChannel
	StreamModeGroup
	StreamModeDM
	StreamModeMatchRelayed
	StreamModeMatchAuthoritative
)
View Source
const API_PREFIX = "/nakama.api.Nakama/"
View Source
const CALLBACKS = "runtime_callbacks"
View Source
const EventsQueueSize = 512
View Source
const LTSentinel = lua.LValueType(-1)
View Source
const RTAPI_PREFIX = "*rtapi.Envelope_"

Variables

View Source
var (
	ErrChannelIdInvalid     = errors.New("invalid channel id")
	ErrChannelCursorInvalid = errors.New("invalid channel cursor")
	ErrChannelGroupNotFound = errors.New("group not found")
)
View Source
var (
	ErrGroupNameInUse        = errors.New("group name in use")
	ErrGroupPermissionDenied = errors.New("group permission denied")
	ErrGroupNoUpdateOps      = errors.New("no group updates")
	ErrGroupNotUpdated       = errors.New("group not updated")
	ErrGroupNotFound         = errors.New("group not found")
	ErrGroupFull             = errors.New("group is full")
	ErrGroupLastSuperadmin   = errors.New("user is last group superadmin")
)
View Source
var (
	ErrLeaderboardNotFound      = errors.New("leaderboard not found")
	ErrLeaderboardAuthoritative = errors.New("leaderboard only allows authoritative submissions")
	ErrLeaderboardInvalidCursor = errors.New("leaderboard cursor invalid")
)
View Source
var (
	MatchFilterValue = uint8(0)
	MatchFilterPtr   = &MatchFilterValue

	MatchFilterAny           = map[uint8]*uint8{StreamModeMatchRelayed: MatchFilterPtr, StreamModeMatchAuthoritative: MatchFilterPtr}
	MatchFilterRelayed       = map[uint8]*uint8{StreamModeMatchRelayed: MatchFilterPtr}
	MatchFilterAuthoritative = map[uint8]*uint8{StreamModeMatchAuthoritative: MatchFilterPtr}
)
View Source
var ErrAccountNotFound = errors.New("account not found")
View Source
var ErrChannelMessageUpdateNotFound = errors.New("channel message not found")
View Source
var ErrMatchmakerTicketNotFound = errors.New("ticket not found")
View Source
var ErrRowsAffectedCount = errors.New("rows_affected_count")
View Source
var ErrSessionQueueFull = errors.New("session outgoing queue full")
View Source
var LSentinel = lua.LValue(&LSentinelType{})

Functions

func AddFriends

func AddFriends(logger *zap.Logger, db *sql.DB, messageRouter MessageRouter, userID uuid.UUID, username string, friendIDs []string) error

func AddGroupUsers

func AddGroupUsers(logger *zap.Logger, db *sql.DB, caller uuid.UUID, groupID uuid.UUID, userIDs []uuid.UUID) error

func AuthenticateCustom

func AuthenticateCustom(logger *zap.Logger, db *sql.DB, customID, username string, create bool) (string, string, bool, error)

func AuthenticateDevice

func AuthenticateDevice(logger *zap.Logger, db *sql.DB, deviceID, username string, create bool) (string, string, bool, error)

func AuthenticateEmail

func AuthenticateEmail(logger *zap.Logger, db *sql.DB, email, password, username string, create bool) (string, string, bool, error)

func AuthenticateFacebook

func AuthenticateFacebook(logger *zap.Logger, db *sql.DB, client *social.Client, accessToken, username string, create bool) (string, string, bool, error)

func AuthenticateGameCenter

func AuthenticateGameCenter(logger *zap.Logger, db *sql.DB, client *social.Client, playerID, bundleID string, timestamp int64, salt, signature, publicKeyUrl, username string, create bool) (string, string, bool, error)

func AuthenticateGoogle

func AuthenticateGoogle(logger *zap.Logger, db *sql.DB, client *social.Client, idToken, username string, create bool) (string, string, bool, error)

func AuthenticateSteam

func AuthenticateSteam(logger *zap.Logger, db *sql.DB, client *social.Client, appID int, publisherKey, token, username string, create bool) (string, string, bool, error)

func BlockFriends

func BlockFriends(logger *zap.Logger, db *sql.DB, currentUser uuid.UUID, ids []string) error

func ChannelMessagesList

func ChannelMessagesList(logger *zap.Logger, db *sql.DB, caller uuid.UUID, stream PresenceStream, channelId string, limit int, forward bool, cursor string) (*api.ChannelMessageList, error)

func ConvertLuaTable added in v0.13.0

func ConvertLuaTable(lv *lua.LTable) map[string]interface{}

func ConvertLuaValue

func ConvertLuaValue(lv lua.LValue) interface{}

func ConvertMap added in v0.13.0

func ConvertMap(l *lua.LState, data map[string]interface{}) *lua.LTable

func ConvertValue

func ConvertValue(l *lua.LState, val interface{}) lua.LValue

func CreateGroup

func CreateGroup(logger *zap.Logger, db *sql.DB, userID uuid.UUID, creatorID uuid.UUID, name, lang, desc, avatarURL, metadata string, open bool, maxCount int) (*api.Group, error)

func DeleteFriends

func DeleteFriends(logger *zap.Logger, db *sql.DB, currentUser uuid.UUID, ids []string) error

func DeleteGroup

func DeleteGroup(logger *zap.Logger, db *sql.DB, groupID uuid.UUID, userID uuid.UUID) error

func DeleteUser

func DeleteUser(tx *sql.Tx, userID uuid.UUID) (int64, error)

func GetAccount

func GetAccount(logger *zap.Logger, db *sql.DB, tracker Tracker, userID uuid.UUID) (*api.Account, error)

func GetChannelMessages

func GetChannelMessages(logger *zap.Logger, db *sql.DB, userID uuid.UUID) ([]*api.ChannelMessage, error)

func GetFriendIDs

func GetFriendIDs(logger *zap.Logger, db *sql.DB, userID uuid.UUID) (*api.Friends, error)

func GetFriends

func GetFriends(logger *zap.Logger, db *sql.DB, tracker Tracker, userID uuid.UUID) (*api.Friends, error)

func GetUsers

func GetUsers(logger *zap.Logger, db *sql.DB, tracker Tracker, ids, usernames, fbIDs []string) (*api.Users, error)

func GroupDeleteAll

func GroupDeleteAll(logger *zap.Logger, tx *sql.Tx, userID uuid.UUID) error

func JoinAttempt

func JoinAttempt(resultCh chan *MatchJoinResult, userID, sessionID uuid.UUID, username, node string) func(mh *MatchHandler)

func JoinGroup

func JoinGroup(logger *zap.Logger, db *sql.DB, groupID uuid.UUID, userID uuid.UUID) error

func KickGroupUsers

func KickGroupUsers(logger *zap.Logger, db *sql.DB, caller uuid.UUID, groupID uuid.UUID, userIDs []uuid.UUID) error

func LeaderboardRecordDelete

func LeaderboardRecordDelete(logger *zap.Logger, db *sql.DB, leaderboardCache LeaderboardCache, caller uuid.UUID, leaderboardId, ownerId string) error

func LeaderboardRecordReadAll

func LeaderboardRecordReadAll(logger *zap.Logger, db *sql.DB, userID uuid.UUID) ([]*api.LeaderboardRecord, error)

func LeaderboardRecordWrite

func LeaderboardRecordWrite(logger *zap.Logger, db *sql.DB, leaderboardCache LeaderboardCache, caller uuid.UUID, leaderboardId, ownerId, username string, score, subscore int64, metadata string) (*api.LeaderboardRecord, error)

func LeaderboardRecordsDeleteAll

func LeaderboardRecordsDeleteAll(logger *zap.Logger, tx *sql.Tx, userID uuid.UUID) error

func LeaderboardRecordsList

func LeaderboardRecordsList(logger *zap.Logger, db *sql.DB, leaderboardCache LeaderboardCache, leaderboardId string, limit *wrappers.Int32Value, cursor string, ownerIds []string) (*api.LeaderboardRecordList, error)

func Leave

func Leave(leaves []*MatchPresence) func(mh *MatchHandler)

func LeaveGroup

func LeaveGroup(logger *zap.Logger, db *sql.DB, groupID uuid.UUID, userID uuid.UUID) error

func ListGroupUsers

func ListGroupUsers(logger *zap.Logger, db *sql.DB, tracker Tracker, groupID uuid.UUID) (*api.GroupUserList, error)

func ListGroups

func ListGroups(logger *zap.Logger, db *sql.DB, name string, limit int, cursorStr string) (*api.GroupList, error)

func ListUserGroups

func ListUserGroups(logger *zap.Logger, db *sql.DB, userID uuid.UUID) (*api.UserGroupList, error)

func ListWalletLedger

func ListWalletLedger(logger *zap.Logger, db *sql.DB, userID uuid.UUID) ([]*walletLedger, error)

func LoadRuntimeModules

func LoadRuntimeModules(startupLogger *zap.Logger, config Config) (map[string]lua.LGFunction, *sync.Map, error)

func NewConfig

func NewConfig(logger *zap.Logger) *config

NewConfig constructs a Config struct which represents server settings, and populates it with default values.

func NewJSONFileLogger

func NewJSONFileLogger(consoleLogger *zap.Logger, fpath string, level zapcore.Level) *zap.Logger

func NewJSONLogger added in v0.12.2

func NewJSONLogger(output *os.File, level zapcore.Level) *zap.Logger

func NewLuaContext added in v0.13.0

func NewLuaContext(l *lua.LState, env *lua.LTable, mode ExecutionMode, uid string, username string, sessionExpiry int64, sid string) *lua.LTable

func NewMultiLogger added in v0.12.2

func NewMultiLogger(loggers ...*zap.Logger) *zap.Logger

func NewSocketWsAcceptor

func NewSocketWsAcceptor(logger *zap.Logger, config Config, sessionRegistry *SessionRegistry, matchmaker Matchmaker, tracker Tracker, jsonpbMarshaler *jsonpb.Marshaler, jsonpbUnmarshaler *jsonpb.Unmarshaler, pipeline *Pipeline) func(http.ResponseWriter, *http.Request)

func NotificationDelete

func NotificationDelete(logger *zap.Logger, db *sql.DB, userID uuid.UUID, notificationIDs []string) error

func NotificationList

func NotificationList(logger *zap.Logger, db *sql.DB, userID uuid.UUID, limit int, cursor string, nc *notificationCacheableCursor) (*api.NotificationList, error)

func NotificationSave

func NotificationSave(logger *zap.Logger, db *sql.DB, notifications map[uuid.UUID][]*api.Notification) error

func NotificationSend

func NotificationSend(logger *zap.Logger, db *sql.DB, messageRouter MessageRouter, notifications map[uuid.UUID][]*api.Notification) error

func OpenOs added in v0.13.0

func OpenOs(L *lua.LState) int

func OpenPackage

func OpenPackage(modules *sync.Map) func(L *lua.LState) int

func PromoteGroupUsers

func PromoteGroupUsers(logger *zap.Logger, db *sql.DB, caller uuid.UUID, groupID uuid.UUID, userIDs []uuid.UUID) error

func SetupLogging added in v1.0.0

func SetupLogging(tmpLogger *zap.Logger, config Config) (*zap.Logger, *zap.Logger)

func StatusError added in v1.4.2

func StatusError(code codes.Code, msg string, cause error) error

Helper function for creating status errors that wrap underlying causes, usually DB errors.

func StorageDeleteObjects

func StorageDeleteObjects(logger *zap.Logger, db *sql.DB, authoritativeDelete bool, userObjectIDs map[uuid.UUID][]*api.DeleteStorageObjectId) (codes.Code, error)

func StorageListObjects

func StorageListObjects(logger *zap.Logger, db *sql.DB, caller uuid.UUID, ownerID uuid.UUID, collection string, limit int, cursor string) (*api.StorageObjectList, codes.Code, error)

func StorageListObjectsPublicRead

func StorageListObjectsPublicRead(logger *zap.Logger, db *sql.DB, collection string, limit int, cursor string, storageCursor *storageCursor) (*api.StorageObjectList, error)

func StorageListObjectsPublicReadUser

func StorageListObjectsPublicReadUser(logger *zap.Logger, db *sql.DB, userID uuid.UUID, collection string, limit int, cursor string, storageCursor *storageCursor) (*api.StorageObjectList, error)

func StorageListObjectsUser

func StorageListObjectsUser(logger *zap.Logger, db *sql.DB, authoritative bool, userID uuid.UUID, collection string, limit int, cursor string, storageCursor *storageCursor) (*api.StorageObjectList, error)

func StorageReadAllUserObjects

func StorageReadAllUserObjects(logger *zap.Logger, db *sql.DB, userID uuid.UUID) ([]*api.StorageObject, error)

func StorageReadObjects

func StorageReadObjects(logger *zap.Logger, db *sql.DB, caller uuid.UUID, objectIDs []*api.ReadStorageObjectId) (*api.StorageObjects, error)

func StorageWriteObjects

func StorageWriteObjects(logger *zap.Logger, db *sql.DB, authoritativeWrite bool, objects map[uuid.UUID][]*api.WriteStorageObject) (*api.StorageObjectAcks, codes.Code, error)

func StreamToChannelId

func StreamToChannelId(stream PresenceStream) (string, error)

func UpdateAccount

func UpdateAccount(db *sql.DB, logger *zap.Logger, userID uuid.UUID, username string,
	displayName, timezone, location, langTag, avatarURL, metadata *wrappers.StringValue) error

func UpdateGroup

func UpdateGroup(logger *zap.Logger, db *sql.DB, groupID uuid.UUID, userID uuid.UUID, creatorID []byte, name, lang, desc, avatar, metadata *wrappers.StringValue, open *wrappers.BoolValue, maxCount int) error

func UpdateWalletLedger

func UpdateWalletLedger(logger *zap.Logger, db *sql.DB, id uuid.UUID, metadata string) (*walletLedger, error)

func UpdateWallets

func UpdateWallets(logger *zap.Logger, db *sql.DB, updates []*walletUpdate) error

func UserExistsAndDoesNotBlock

func UserExistsAndDoesNotBlock(db *sql.DB, checkUserID, blocksUserID uuid.UUID) (bool, error)

Types

type ApiServer

type ApiServer struct {
	// contains filtered or unexported fields
}

func StartApiServer

func StartApiServer(logger *zap.Logger, startupLogger *zap.Logger, db *sql.DB, jsonpbMarshaler *jsonpb.Marshaler, jsonpbUnmarshaler *jsonpb.Unmarshaler, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, sessionRegistry *SessionRegistry, matchRegistry MatchRegistry, matchmaker Matchmaker, tracker Tracker, router MessageRouter, pipeline *Pipeline, runtimePool *RuntimePool) *ApiServer

func (*ApiServer) AddFriends

func (s *ApiServer) AddFriends(ctx context.Context, in *api.AddFriendsRequest) (*empty.Empty, error)

func (*ApiServer) AddGroupUsers

func (s *ApiServer) AddGroupUsers(ctx context.Context, in *api.AddGroupUsersRequest) (*empty.Empty, error)

func (*ApiServer) AuthenticateCustom

func (s *ApiServer) AuthenticateCustom(ctx context.Context, in *api.AuthenticateCustomRequest) (*api.Session, error)

func (*ApiServer) AuthenticateDevice

func (s *ApiServer) AuthenticateDevice(ctx context.Context, in *api.AuthenticateDeviceRequest) (*api.Session, error)

func (*ApiServer) AuthenticateEmail

func (s *ApiServer) AuthenticateEmail(ctx context.Context, in *api.AuthenticateEmailRequest) (*api.Session, error)

func (*ApiServer) AuthenticateFacebook

func (s *ApiServer) AuthenticateFacebook(ctx context.Context, in *api.AuthenticateFacebookRequest) (*api.Session, error)

func (*ApiServer) AuthenticateGameCenter

func (s *ApiServer) AuthenticateGameCenter(ctx context.Context, in *api.AuthenticateGameCenterRequest) (*api.Session, error)

func (*ApiServer) AuthenticateGoogle

func (s *ApiServer) AuthenticateGoogle(ctx context.Context, in *api.AuthenticateGoogleRequest) (*api.Session, error)

func (*ApiServer) AuthenticateSteam

func (s *ApiServer) AuthenticateSteam(ctx context.Context, in *api.AuthenticateSteamRequest) (*api.Session, error)

func (*ApiServer) BlockFriends

func (s *ApiServer) BlockFriends(ctx context.Context, in *api.BlockFriendsRequest) (*empty.Empty, error)

func (*ApiServer) CreateGroup

func (s *ApiServer) CreateGroup(ctx context.Context, in *api.CreateGroupRequest) (*api.Group, error)

func (*ApiServer) DeleteFriends

func (s *ApiServer) DeleteFriends(ctx context.Context, in *api.DeleteFriendsRequest) (*empty.Empty, error)

func (*ApiServer) DeleteGroup

func (s *ApiServer) DeleteGroup(ctx context.Context, in *api.DeleteGroupRequest) (*empty.Empty, error)

func (*ApiServer) DeleteLeaderboardRecord

func (s *ApiServer) DeleteLeaderboardRecord(ctx context.Context, in *api.DeleteLeaderboardRecordRequest) (*empty.Empty, error)

func (*ApiServer) DeleteNotifications

func (s *ApiServer) DeleteNotifications(ctx context.Context, in *api.DeleteNotificationsRequest) (*empty.Empty, error)

func (*ApiServer) DeleteStorageObjects

func (s *ApiServer) DeleteStorageObjects(ctx context.Context, in *api.DeleteStorageObjectsRequest) (*empty.Empty, error)

func (*ApiServer) GetAccount

func (s *ApiServer) GetAccount(ctx context.Context, in *empty.Empty) (*api.Account, error)

func (*ApiServer) GetUsers

func (s *ApiServer) GetUsers(ctx context.Context, in *api.GetUsersRequest) (*api.Users, error)

func (*ApiServer) Healthcheck

func (s *ApiServer) Healthcheck(ctx context.Context, in *empty.Empty) (*empty.Empty, error)

func (*ApiServer) ImportFacebookFriends

func (s *ApiServer) ImportFacebookFriends(ctx context.Context, in *api.ImportFacebookFriendsRequest) (*empty.Empty, error)

func (*ApiServer) JoinGroup

func (s *ApiServer) JoinGroup(ctx context.Context, in *api.JoinGroupRequest) (*empty.Empty, error)

func (*ApiServer) KickGroupUsers

func (s *ApiServer) KickGroupUsers(ctx context.Context, in *api.KickGroupUsersRequest) (*empty.Empty, error)

func (*ApiServer) LeaveGroup

func (s *ApiServer) LeaveGroup(ctx context.Context, in *api.LeaveGroupRequest) (*empty.Empty, error)

func (*ApiServer) LinkCustom

func (s *ApiServer) LinkCustom(ctx context.Context, in *api.AccountCustom) (*empty.Empty, error)

func (*ApiServer) LinkDevice

func (s *ApiServer) LinkDevice(ctx context.Context, in *api.AccountDevice) (*empty.Empty, error)

func (*ApiServer) LinkEmail

func (s *ApiServer) LinkEmail(ctx context.Context, in *api.AccountEmail) (*empty.Empty, error)

func (*ApiServer) LinkFacebook

func (s *ApiServer) LinkFacebook(ctx context.Context, in *api.LinkFacebookRequest) (*empty.Empty, error)

func (*ApiServer) LinkGameCenter

func (s *ApiServer) LinkGameCenter(ctx context.Context, in *api.AccountGameCenter) (*empty.Empty, error)

func (*ApiServer) LinkGoogle

func (s *ApiServer) LinkGoogle(ctx context.Context, in *api.AccountGoogle) (*empty.Empty, error)

func (*ApiServer) LinkSteam

func (s *ApiServer) LinkSteam(ctx context.Context, in *api.AccountSteam) (*empty.Empty, error)

func (*ApiServer) ListChannelMessages

func (s *ApiServer) ListChannelMessages(ctx context.Context, in *api.ListChannelMessagesRequest) (*api.ChannelMessageList, error)

func (*ApiServer) ListFriends

func (s *ApiServer) ListFriends(ctx context.Context, in *empty.Empty) (*api.Friends, error)

func (*ApiServer) ListGroupUsers

func (s *ApiServer) ListGroupUsers(ctx context.Context, in *api.ListGroupUsersRequest) (*api.GroupUserList, error)

func (*ApiServer) ListGroups

func (s *ApiServer) ListGroups(ctx context.Context, in *api.ListGroupsRequest) (*api.GroupList, error)

func (*ApiServer) ListLeaderboardRecords

func (s *ApiServer) ListLeaderboardRecords(ctx context.Context, in *api.ListLeaderboardRecordsRequest) (*api.LeaderboardRecordList, error)

func (*ApiServer) ListMatches

func (s *ApiServer) ListMatches(ctx context.Context, in *api.ListMatchesRequest) (*api.MatchList, error)

func (*ApiServer) ListNotifications

func (s *ApiServer) ListNotifications(ctx context.Context, in *api.ListNotificationsRequest) (*api.NotificationList, error)

func (*ApiServer) ListStorageObjects

func (s *ApiServer) ListStorageObjects(ctx context.Context, in *api.ListStorageObjectsRequest) (*api.StorageObjectList, error)

func (*ApiServer) ListUserGroups

func (s *ApiServer) ListUserGroups(ctx context.Context, in *api.ListUserGroupsRequest) (*api.UserGroupList, error)

func (*ApiServer) PromoteGroupUsers

func (s *ApiServer) PromoteGroupUsers(ctx context.Context, in *api.PromoteGroupUsersRequest) (*empty.Empty, error)

func (*ApiServer) ReadStorageObjects

func (s *ApiServer) ReadStorageObjects(ctx context.Context, in *api.ReadStorageObjectsRequest) (*api.StorageObjects, error)

func (*ApiServer) RpcFunc

func (s *ApiServer) RpcFunc(ctx context.Context, in *api.Rpc) (*api.Rpc, error)

func (*ApiServer) Stop

func (s *ApiServer) Stop()

func (*ApiServer) UnlinkCustom

func (s *ApiServer) UnlinkCustom(ctx context.Context, in *api.AccountCustom) (*empty.Empty, error)

func (*ApiServer) UnlinkDevice

func (s *ApiServer) UnlinkDevice(ctx context.Context, in *api.AccountDevice) (*empty.Empty, error)

func (*ApiServer) UnlinkEmail

func (s *ApiServer) UnlinkEmail(ctx context.Context, in *api.AccountEmail) (*empty.Empty, error)

func (*ApiServer) UnlinkFacebook

func (s *ApiServer) UnlinkFacebook(ctx context.Context, in *api.AccountFacebook) (*empty.Empty, error)

func (*ApiServer) UnlinkGameCenter

func (s *ApiServer) UnlinkGameCenter(ctx context.Context, in *api.AccountGameCenter) (*empty.Empty, error)

func (*ApiServer) UnlinkGoogle

func (s *ApiServer) UnlinkGoogle(ctx context.Context, in *api.AccountGoogle) (*empty.Empty, error)

func (*ApiServer) UnlinkSteam

func (s *ApiServer) UnlinkSteam(ctx context.Context, in *api.AccountSteam) (*empty.Empty, error)

func (*ApiServer) UpdateAccount

func (s *ApiServer) UpdateAccount(ctx context.Context, in *api.UpdateAccountRequest) (*empty.Empty, error)

func (*ApiServer) UpdateGroup

func (s *ApiServer) UpdateGroup(ctx context.Context, in *api.UpdateGroupRequest) (*empty.Empty, error)

func (*ApiServer) WriteLeaderboardRecord

func (s *ApiServer) WriteLeaderboardRecord(ctx context.Context, in *api.WriteLeaderboardRecordRequest) (*api.LeaderboardRecord, error)

func (*ApiServer) WriteStorageObjects

func (s *ApiServer) WriteStorageObjects(ctx context.Context, in *api.WriteStorageObjectsRequest) (*api.StorageObjectAcks, error)

type Callbacks added in v0.13.0

type Callbacks struct {
	RPC        map[string]*lua.LFunction
	Before     map[string]*lua.LFunction
	After      map[string]*lua.LFunction
	Matchmaker *lua.LFunction
}

type ChannelIdToStreamResult

type ChannelIdToStreamResult struct {
	Stream PresenceStream
}

Wrapper type to avoid allocating a stream struct when the input is invalid.

func ChannelIdToStream

func ChannelIdToStream(channelId string) (*ChannelIdToStreamResult, error)

type Config

type Config interface {
	GetName() string
	GetDataDir() string
	GetLogger() *LoggerConfig
	GetMetrics() *MetricsConfig
	GetSession() *SessionConfig
	GetSocket() *SocketConfig
	GetDatabase() *DatabaseConfig
	GetSocial() *SocialConfig
	GetRuntime() *RuntimeConfig
	GetConsole() *ConsoleConfig
}

Config interface is the Nakama core configuration.

func ParseArgs added in v1.0.0

func ParseArgs(logger *zap.Logger, args []string) Config

type ConsoleConfig

type ConsoleConfig struct {
	Port     int    `yaml:"port" json:"port" usage:"The port for accepting connections for the embedded console, listening on all interfaces."`
	Username string `yaml:"username" json:"username" usage:"Username for the embedded console."`
	Password string `yaml:"password" json:"password" usage:"Password for the embedded console."`
}

ConsoleConfig is configuration relevant to the embedded console.

func NewConsoleConfig

func NewConsoleConfig() *ConsoleConfig

NewConsoleConfig creates a new ConsoleConfig struct.

type ConsoleServer

type ConsoleServer struct {
	// contains filtered or unexported fields
}

func StartConsoleServer

func StartConsoleServer(logger *zap.Logger, startupLogger *zap.Logger, config Config, db *sql.DB) *ConsoleServer

func (*ConsoleServer) DeleteAccount

func (s *ConsoleServer) DeleteAccount(ctx context.Context, in *console.AccountIdRequest) (*empty.Empty, error)

func (*ConsoleServer) ExportAccount

func (*ConsoleServer) Login

func (*ConsoleServer) Stop

func (s *ConsoleServer) Stop()

type DatabaseConfig

type DatabaseConfig struct {
	Addresses         []string `yaml:"address" json:"address" usage:"List of CockroachDB servers (username:password@address:port/dbname)."`
	ConnMaxLifetimeMs int      `` /* 173-byte string literal not displayed */
	MaxOpenConns      int      `yaml:"max_open_conns" json:"max_open_conns" usage:"Maximum number of allowed open connections to the database."`
	MaxIdleConns      int      `yaml:"max_idle_conns" json:"max_idle_conns" usage:"Maximum number of allowed open but unused connections to the database."`
}

DatabaseConfig is configuration relevant to the Database storage.

func NewDatabaseConfig

func NewDatabaseConfig() *DatabaseConfig

NewDatabaseConfig creates a new DatabaseConfig struct.

type ExecutionMode added in v0.13.0

type ExecutionMode int
const (
	ExecutionModeRunOnce ExecutionMode = iota
	ExecutionModeRPC
	ExecutionModeBefore
	ExecutionModeAfter
	ExecutionModeMatch
	ExecutionModeMatchmaker
)

func (ExecutionMode) String added in v0.13.0

func (e ExecutionMode) String() string

type LSentinelType

type LSentinelType struct {
	lua.LNilType
}

func (*LSentinelType) String

func (s *LSentinelType) String() string

func (*LSentinelType) Type

func (s *LSentinelType) Type() lua.LValueType

type Leaderboard

type Leaderboard struct {
	Id            string
	Authoritative bool
	SortOrder     int
	Operator      int
	ResetSchedule *cronexpr.Expression
	Metadata      string
	CreateTime    int64
}

type LeaderboardCache

type LeaderboardCache interface {
	Get(id string) *Leaderboard
	Create(id string, authoritative bool, sortOrder, operator int, resetSchedule, metadata string) error
	Delete(id string) error
}

func NewLocalLeaderboardCache

func NewLocalLeaderboardCache(logger, startupLogger *zap.Logger, db *sql.DB) LeaderboardCache

type LocalLeaderboardCache

type LocalLeaderboardCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*LocalLeaderboardCache) Create

func (l *LocalLeaderboardCache) Create(id string, authoritative bool, sortOrder, operator int, resetSchedule, metadata string) error

func (*LocalLeaderboardCache) Delete

func (l *LocalLeaderboardCache) Delete(id string) error

func (*LocalLeaderboardCache) Get

type LocalMatchRegistry

type LocalMatchRegistry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*LocalMatchRegistry) GetMatch

func (r *LocalMatchRegistry) GetMatch(id uuid.UUID) *MatchHandler

func (*LocalMatchRegistry) Join

func (r *LocalMatchRegistry) Join(id uuid.UUID, node string, userID, sessionID uuid.UUID, username, fromNode string) (bool, bool, string, string)

func (*LocalMatchRegistry) Kick

func (r *LocalMatchRegistry) Kick(stream PresenceStream, presences []*MatchPresence)

func (*LocalMatchRegistry) Leave

func (r *LocalMatchRegistry) Leave(id uuid.UUID, presences []*MatchPresence)

func (*LocalMatchRegistry) ListMatches

func (r *LocalMatchRegistry) ListMatches(limit int, authoritative *wrappers.BoolValue, label *wrappers.StringValue, minSize *wrappers.Int32Value, maxSize *wrappers.Int32Value) []*api.Match

func (*LocalMatchRegistry) NewMatch

func (r *LocalMatchRegistry) NewMatch(name string, params interface{}) (*MatchHandler, error)

func (*LocalMatchRegistry) RemoveMatch

func (r *LocalMatchRegistry) RemoveMatch(id uuid.UUID, stream PresenceStream)

func (*LocalMatchRegistry) SendData

func (r *LocalMatchRegistry) SendData(id uuid.UUID, node string, userID, sessionID uuid.UUID, username, fromNode string, opCode int64, data []byte)

func (*LocalMatchRegistry) Stop

func (r *LocalMatchRegistry) Stop()

type LocalMatchmaker

type LocalMatchmaker struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*LocalMatchmaker) Add

func (m *LocalMatchmaker) Add(session Session, query string, minCount int, maxCount int, stringProperties map[string]string, numericProperties map[string]float64) (string, []*MatchmakerEntry, error)

func (*LocalMatchmaker) Remove

func (m *LocalMatchmaker) Remove(sessionID uuid.UUID, ticket string) error

func (*LocalMatchmaker) RemoveAll

func (m *LocalMatchmaker) RemoveAll(sessionID uuid.UUID) error

type LocalMessageRouter

type LocalMessageRouter struct {
	// contains filtered or unexported fields
}

func (*LocalMessageRouter) SendToPresenceIDs

func (r *LocalMessageRouter) SendToPresenceIDs(logger *zap.Logger, presenceIDs []*PresenceID, envelope *rtapi.Envelope)

func (*LocalMessageRouter) SendToStream

func (r *LocalMessageRouter) SendToStream(logger *zap.Logger, stream PresenceStream, envelope *rtapi.Envelope)

type LocalTracker

type LocalTracker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*LocalTracker) Count

func (t *LocalTracker) Count() int

func (*LocalTracker) CountByStream

func (t *LocalTracker) CountByStream(stream PresenceStream) int

func (*LocalTracker) CountByStreamModeFilter

func (t *LocalTracker) CountByStreamModeFilter(modes map[uint8]*uint8) map[*PresenceStream]int32

func (*LocalTracker) GetLocalBySessionIDStreamUserID

func (t *LocalTracker) GetLocalBySessionIDStreamUserID(sessionID uuid.UUID, stream PresenceStream, userID uuid.UUID) *PresenceMeta

func (*LocalTracker) ListByStream

func (t *LocalTracker) ListByStream(stream PresenceStream, includeHidden bool) []*Presence

func (*LocalTracker) ListLocalSessionIDByStream

func (t *LocalTracker) ListLocalSessionIDByStream(stream PresenceStream) []uuid.UUID

func (*LocalTracker) ListNodesForStream

func (t *LocalTracker) ListNodesForStream(stream PresenceStream) map[string]struct{}

func (*LocalTracker) ListPresenceIDByStream

func (t *LocalTracker) ListPresenceIDByStream(stream PresenceStream) []*PresenceID

func (*LocalTracker) SetMatchLeaveListener

func (t *LocalTracker) SetMatchLeaveListener(f func(id uuid.UUID, leaves []*MatchPresence))

func (*LocalTracker) Stop

func (t *LocalTracker) Stop()

func (*LocalTracker) StreamExists

func (t *LocalTracker) StreamExists(stream PresenceStream) bool

func (*LocalTracker) Track

func (t *LocalTracker) Track(sessionID uuid.UUID, stream PresenceStream, userID uuid.UUID, meta PresenceMeta, allowIfFirstForSession bool) (bool, bool)

func (*LocalTracker) Untrack

func (t *LocalTracker) Untrack(sessionID uuid.UUID, stream PresenceStream, userID uuid.UUID)

func (*LocalTracker) UntrackAll

func (t *LocalTracker) UntrackAll(sessionID uuid.UUID)

func (*LocalTracker) UntrackByStream

func (t *LocalTracker) UntrackByStream(stream PresenceStream)

func (*LocalTracker) UntrackLocalByStream

func (t *LocalTracker) UntrackLocalByStream(stream PresenceStream)

func (*LocalTracker) Update

func (t *LocalTracker) Update(sessionID uuid.UUID, stream PresenceStream, userID uuid.UUID, meta PresenceMeta, allowIfFirstForSession bool) bool

type LoggerConfig

type LoggerConfig struct {
	Level  string `yaml:"level" json:"level" usage:"Log level to set. Valid values are 'debug', 'info', 'warn', 'error'. "`
	Stdout bool   `yaml:"stdout" json:"stdout" usage:"Log to standard console output (as well as to a file if set)."`
	File   string `` /* 135-byte string literal not displayed */
}

LoggerConfig is configuration relevant to logging levels and output.

func NewLoggerConfig

func NewLoggerConfig() *LoggerConfig

NewLogConfig creates a new LoggerConfig struct.

type MatchDataMessage

type MatchDataMessage struct {
	UserID    uuid.UUID
	SessionID uuid.UUID
	Username  string
	Node      string
	OpCode    int64
	Data      []byte
}

type MatchHandler

type MatchHandler struct {
	sync.Mutex

	// Identification not (directly) controlled by match init.
	ID     uuid.UUID
	Node   string
	IDStr  string
	Stream PresenceStream

	// Immutable configuration set by match init.
	Label string
	Rate  int
	// contains filtered or unexported fields
}

func NewMatchHandler

func NewMatchHandler(logger *zap.Logger, db *sql.DB, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, sessionRegistry *SessionRegistry, matchRegistry MatchRegistry, tracker Tracker, router MessageRouter, stdLibs map[string]lua.LGFunction, once *sync.Once, id uuid.UUID, node string, name string, params interface{}) (*MatchHandler, error)

func (*MatchHandler) Close

func (mh *MatchHandler) Close()

Used when the match is closed externally.

func (*MatchHandler) QueueCall

func (mh *MatchHandler) QueueCall(f func(*MatchHandler)) bool

func (*MatchHandler) QueueData

func (mh *MatchHandler) QueueData(m *MatchDataMessage)

func (*MatchHandler) Stop

func (mh *MatchHandler) Stop()

Used when an internal match process (or error) requires it to stop.

type MatchJoinResult

type MatchJoinResult struct {
	Allow  bool
	Reason string
	Label  string
}

type MatchPresence

type MatchPresence struct {
	Node      string
	UserID    uuid.UUID
	SessionID uuid.UUID
	Username  string
}

type MatchRegistry

type MatchRegistry interface {
	// Create and start a new match, given a Lua module name.
	NewMatch(name string, params interface{}) (*MatchHandler, error)
	// Return a match handler by ID, only from the local node.
	GetMatch(id uuid.UUID) *MatchHandler
	// Remove a tracked match and ensure all its presences are cleaned up.
	// Does not ensure the match process itself is no longer running, that must be handled separately.
	RemoveMatch(id uuid.UUID, stream PresenceStream)
	// List (and optionally filter) currently running matches.
	// This can list across both authoritative and relayed matches.
	ListMatches(limit int, authoritative *wrappers.BoolValue, label *wrappers.StringValue, minSize *wrappers.Int32Value, maxSize *wrappers.Int32Value) []*api.Match
	// Stop the match registry and close all matches it's tracking.
	Stop()

	// Pass a user join attempt to a match handler. Returns if the match was found, if the join was accepted, a reason for any rejection, and the match label.
	Join(id uuid.UUID, node string, userID, sessionID uuid.UUID, username, fromNode string) (bool, bool, string, string)
	// Notify a match handler that a user has left or disconnected.
	// Expects that the caller has already determined the match is hosted on the current node.
	Leave(id uuid.UUID, presences []*MatchPresence)
	// Called by match handlers to request the removal fo a match participant.
	Kick(stream PresenceStream, presences []*MatchPresence)
	// Pass a data payload (usually from a user) to the appropriate match handler.
	// Assumes that the data sender has already been validated as a match participant before this call.
	SendData(id uuid.UUID, node string, userID, sessionID uuid.UUID, username, fromNode string, opCode int64, data []byte)
}

func NewLocalMatchRegistry

func NewLocalMatchRegistry(logger *zap.Logger, db *sql.DB, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, sessionRegistry *SessionRegistry, tracker Tracker, router MessageRouter, stdLibs map[string]lua.LGFunction, once *sync.Once, node string) MatchRegistry

type Matchmaker added in v0.13.0

type Matchmaker interface {
	Add(session Session, query string, minCount int, maxCount int, stringProperties map[string]string, numericProperties map[string]float64) (string, []*MatchmakerEntry, error)
	Remove(sessionID uuid.UUID, ticket string) error
	RemoveAll(sessionID uuid.UUID) error
}

func NewLocalMatchmaker

func NewLocalMatchmaker(startupLogger *zap.Logger, node string) Matchmaker

type MatchmakerEntry

type MatchmakerEntry struct {
	Ticket     string                 `json:"ticket"`
	Presence   *MatchmakerPresence    `json:"presence"`
	Properties map[string]interface{} `json:"properties"`
	// Cached for when we need them returned to clients, but not indexed.
	StringProperties  map[string]string  `json:"-"`
	NumericProperties map[string]float64 `json:"-"`
	SessionID         uuid.UUID          `json:"-"`
}

type MatchmakerPresence

type MatchmakerPresence struct {
	UserId    string `json:"user_id"`
	SessionId string `json:"session_id"`
	Username  string `json:"username"`
	Node      string `json:"node"`
}

type MessageRouter

type MessageRouter interface {
	SendToPresenceIDs(*zap.Logger, []*PresenceID, *rtapi.Envelope)
	SendToStream(*zap.Logger, PresenceStream, *rtapi.Envelope)
}

MessageRouter is responsible for sending a message to a list of presences or to an entire stream.

func NewLocalMessageRouter

func NewLocalMessageRouter(sessionRegistry *SessionRegistry, tracker Tracker, jsonpbMarshaler *jsonpb.Marshaler) MessageRouter

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(logger, startupLogger *zap.Logger, config Config) *Metrics

func (*Metrics) Stop

func (m *Metrics) Stop(logger *zap.Logger)

type MetricsConfig

type MetricsConfig struct {
	ReportingFreqSec     int    `yaml:"reporting_freq_sec" json:"reporting_freq_sec" usage:"Frequency of metrics exports. Default is 10 seconds."`
	StackdriverProjectID string `` /* 218-byte string literal not displayed */
	Namespace            string `` /* 135-byte string literal not displayed */
	PrometheusPort       int    `yaml:"prometheus_port" json:"prometheus_port" usage:"Port to expose Prometheus. If '0' Prometheus exports are disabled."`
}

MetricsConfig is configuration relevant to metrics capturing and output.

func NewMetricsConfig

func NewMetricsConfig() *MetricsConfig

NewMetricsConfig creates a new MatricsConfig struct.

type NakamaModule added in v0.13.0

type NakamaModule struct {
	// contains filtered or unexported fields
}

func NewNakamaModule added in v0.13.0

func NewNakamaModule(logger *zap.Logger, db *sql.DB, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, l *lua.LState, sessionRegistry *SessionRegistry, matchRegistry MatchRegistry, tracker Tracker, router MessageRouter, once *sync.Once, announceCallback func(ExecutionMode, string)) *NakamaModule

func (*NakamaModule) Loader added in v0.13.0

func (n *NakamaModule) Loader(l *lua.LState) int

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

func NewPipeline

func NewPipeline(config Config, db *sql.DB, jsonpbMarshaler *jsonpb.Marshaler, jsonpbUnmarshaler *jsonpb.Unmarshaler, sessionRegistry *SessionRegistry, matchRegistry MatchRegistry, matchmaker Matchmaker, tracker Tracker, router MessageRouter, runtimePool *RuntimePool) *Pipeline

func (*Pipeline) ProcessRequest

func (p *Pipeline) ProcessRequest(logger *zap.Logger, session Session, envelope *rtapi.Envelope) bool

type Presence

type Presence struct {
	ID     PresenceID
	Stream PresenceStream
	UserID uuid.UUID
	Meta   PresenceMeta
}

type PresenceEvent

type PresenceEvent struct {
	Joins  []Presence
	Leaves []Presence
}

type PresenceID

type PresenceID struct {
	Node      string
	SessionID uuid.UUID
}

type PresenceMeta

type PresenceMeta struct {
	Format      SessionFormat
	Hidden      bool
	Persistence bool
	Username    string
	Status      string
}

type PresenceStream

type PresenceStream struct {
	Mode       uint8
	Subject    uuid.UUID
	Descriptor uuid.UUID
	Label      string
}

type RegCallbacks

type RegCallbacks struct {
	RPC        map[string]interface{}
	Before     map[string]interface{}
	After      map[string]interface{}
	Matchmaker interface{}
}

func ValidateRuntimeModules

func ValidateRuntimeModules(logger, startupLogger *zap.Logger, db *sql.DB, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, sessionRegistry *SessionRegistry, matchRegistry MatchRegistry, tracker Tracker, router MessageRouter, stdLibs map[string]lua.LGFunction, modules *sync.Map, once *sync.Once) (*RegCallbacks, error)

type Runtime added in v0.13.0

type Runtime struct {
	// contains filtered or unexported fields
}

func (*Runtime) GetCallback

func (r *Runtime) GetCallback(e ExecutionMode, key string) *lua.LFunction

func (*Runtime) InvokeFunction

func (r *Runtime) InvokeFunction(execMode ExecutionMode, fn *lua.LFunction, uid string, username string, sessionExpiry int64, sid string, payload interface{}) (interface{}, error, codes.Code)

func (*Runtime) NewStateThread added in v0.13.0

func (r *Runtime) NewStateThread() (*lua.LState, context.CancelFunc)

func (*Runtime) Stop added in v0.13.0

func (r *Runtime) Stop()

type RuntimeConfig added in v0.13.0

type RuntimeConfig struct {
	Environment map[string]interface{}
	Env         []string `yaml:"env" json:"env"`
	Path        string   `yaml:"path" json:"path" usage:"Path for the server to scan for *.lua files."`
	HTTPKey     string   `yaml:"http_key" json:"http_key" usage:"Runtime HTTP Invocation key."`
}

RuntimeConfig is configuration relevant to the Runtime Lua VM.

func NewRuntimeConfig added in v0.13.0

func NewRuntimeConfig() *RuntimeConfig

NewRuntimeConfig creates a new RuntimeConfig struct.

type RuntimeModule added in v1.1.0

type RuntimeModule struct {
	Name    string
	Path    string
	Content []byte
}

type RuntimePool added in v1.1.0

type RuntimePool struct {
	// contains filtered or unexported fields
}

func NewRuntimePool added in v1.1.0

func NewRuntimePool(logger *zap.Logger, db *sql.DB, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, sessionRegistry *SessionRegistry, matchRegistry MatchRegistry, tracker Tracker, router MessageRouter, stdLibs map[string]lua.LGFunction, modules *sync.Map, regCallbacks *RegCallbacks, once *sync.Once) *RuntimePool

func (*RuntimePool) Get added in v1.1.0

func (rp *RuntimePool) Get() *Runtime

func (*RuntimePool) HasCallback

func (rp *RuntimePool) HasCallback(mode ExecutionMode, id string) bool

func (*RuntimePool) Put added in v1.1.0

func (rp *RuntimePool) Put(r *Runtime)

type Session

type Session interface {
	Logger() *zap.Logger
	ID() uuid.UUID
	UserID() uuid.UUID

	Username() string
	SetUsername(string)

	Expiry() int64
	Consume(func(logger *zap.Logger, session Session, envelope *rtapi.Envelope) bool)

	Format() SessionFormat
	Send(envelope *rtapi.Envelope) error
	SendBytes(payload []byte) error

	Close()
}

func NewSessionWS

func NewSessionWS(logger *zap.Logger, config Config, userID uuid.UUID, username string, expiry int64, jsonpbMarshaler *jsonpb.Marshaler, jsonpbUnmarshaler *jsonpb.Unmarshaler, conn *websocket.Conn, sessionRegistry *SessionRegistry, matchmaker Matchmaker, tracker Tracker) Session

type SessionConfig

type SessionConfig struct {
	EncryptionKey  string `yaml:"encryption_key" json:"encryption_key" usage:"The encryption key used to produce the client token."`
	TokenExpirySec int64  `yaml:"token_expiry_sec" json:"token_expiry_sec" usage:"Token expiry in seconds."`
}

SessionConfig is configuration relevant to the session.

func NewSessionConfig

func NewSessionConfig() *SessionConfig

NewSessionConfig creates a new SessionConfig struct.

type SessionFormat added in v1.2.0

type SessionFormat uint8
const (
	SessionFormatJson SessionFormat = iota
	SessionFormatProtobuf
)

type SessionRegistry

type SessionRegistry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SessionRegistry maintains a thread-safe list of sessions to their IDs.

func NewSessionRegistry

func NewSessionRegistry() *SessionRegistry

func (*SessionRegistry) Get

func (r *SessionRegistry) Get(sessionID uuid.UUID) Session

func (*SessionRegistry) Stop

func (r *SessionRegistry) Stop()

type SocialConfig

type SocialConfig struct {
	Steam *SocialConfigSteam `yaml:"steam" json:"steam" usage:"Steam configuration."`
}

SocialConfig is configuration relevant to the social authentication providers.

func NewSocialConfig

func NewSocialConfig() *SocialConfig

NewSocialConfig creates a new SocialConfig struct.

type SocialConfigSteam

type SocialConfigSteam struct {
	PublisherKey string `yaml:"publisher_key" json:"publisher_key" usage:"Steam Publisher Key value."`
	AppID        int    `yaml:"app_id" json:"app_id" usage:"Steam App ID."`
}

SocialConfigSteam is configuration relevant to Steam

type SocketConfig added in v1.0.0

type SocketConfig struct {
	ServerKey           string            `yaml:"server_key" json:"server_key" usage:"Server key to use to establish a connection to the server."`
	Port                int               `yaml:"port" json:"port" usage:"The port for accepting connections from the client, listening on all interfaces."`
	MaxMessageSizeBytes int64             `` /* 201-byte string literal not displayed */
	ReadTimeoutMs       int               `` /* 145-byte string literal not displayed */
	WriteTimeoutMs      int               `` /* 157-byte string literal not displayed */
	IdleTimeoutMs       int               `` /* 178-byte string literal not displayed */
	WriteWaitMs         int               `` /* 156-byte string literal not displayed */
	PongWaitMs          int               `` /* 156-byte string literal not displayed */
	PingPeriodMs        int               `` /* 204-byte string literal not displayed */
	OutgoingQueueSize   int               `` /* 245-byte string literal not displayed */
	SSLCertificate      string            `` /* 192-byte string literal not displayed */
	SSLPrivateKey       string            `` /* 192-byte string literal not displayed */
	TLSCert             []tls.Certificate // Created by processing SSLCertificate and SSLPrivateKey, not set from input args directly.
}

SocketConfig is configuration relevant to the transport socket and protocol.

func NewSocketConfig added in v1.0.0

func NewSocketConfig() *SocketConfig

NewTransportConfig creates a new TransportConfig struct.

type Tracker

type Tracker interface {
	SetMatchLeaveListener(func(id uuid.UUID, leaves []*MatchPresence))
	Stop()

	// Track returns success true/false, and new presence true/false.
	Track(sessionID uuid.UUID, stream PresenceStream, userID uuid.UUID, meta PresenceMeta, allowIfFirstForSession bool) (bool, bool)
	Untrack(sessionID uuid.UUID, stream PresenceStream, userID uuid.UUID)
	UntrackAll(sessionID uuid.UUID)
	// Update returns success true/false - will only fail if the user has no presence and allowIfFirstForSession is false, otherwise is an upsert.
	Update(sessionID uuid.UUID, stream PresenceStream, userID uuid.UUID, meta PresenceMeta, allowIfFirstForSession bool) bool

	// Remove all presences on a stream, effectively closing it.
	UntrackByStream(stream PresenceStream)
	// Remove all presences on a stream from the local node.
	UntrackLocalByStream(stream PresenceStream)

	// List the nodes that have at least one presence for the given stream.
	ListNodesForStream(stream PresenceStream) map[string]struct{}

	// Check if a stream exists (has any presences) or not.
	StreamExists(stream PresenceStream) bool
	// Get current total number of presences.
	Count() int
	// Get the number of presences in the given stream.
	CountByStream(stream PresenceStream) int
	// Get a snapshot of current presence counts for streams with one of the given stream modes.
	CountByStreamModeFilter(modes map[uint8]*uint8) map[*PresenceStream]int32
	// Check if a single presence on the current node exists.
	GetLocalBySessionIDStreamUserID(sessionID uuid.UUID, stream PresenceStream, userID uuid.UUID) *PresenceMeta
	// List presences by stream, optionally include hidden ones.
	ListByStream(stream PresenceStream, includeHidden bool) []*Presence

	// Fast lookup of local session IDs to use for message delivery.
	ListLocalSessionIDByStream(stream PresenceStream) []uuid.UUID
	// Fast lookup of node + session IDs to use for message delivery.
	ListPresenceIDByStream(stream PresenceStream) []*PresenceID
}

func StartLocalTracker

func StartLocalTracker(logger *zap.Logger, sessionRegistry *SessionRegistry, jsonpbMarshaler *jsonpb.Marshaler, name string) Tracker

Jump to

Keyboard shortcuts

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