server

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2017 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NOTIFICATION_DM_REQUEST         int64 = 1
	NOTIFICATION_FRIEND_REQUEST     int64 = 2
	NOTIFICATION_FRIEND_ACCEPT      int64 = 3
	NOTIFICATION_GROUP_ADD          int64 = 4
	NOTIFICATION_GROUP_JOIN_REQUEST int64 = 5
	NOTIFICATION_FRIEND_JOIN_GAME   int64 = 6
)
View Source
const CALLBACKS = "runtime_callbacks"

Variables

View Source
var RUNTIME_MESSAGES = map[string]string{
	"*server.AuthenticateRequest_Device":       "authenticaterequest_device",
	"*server.AuthenticateRequest_Custom":       "authenticaterequest_custom",
	"*server.AuthenticateRequest_Email_":       "authenticaterequest_email",
	"*server.AuthenticateRequest_Facebook":     "authenticaterequest_facebook",
	"*server.AuthenticateRequest_Google":       "authenticaterequest_google",
	"*server.AuthenticateRequest_Steam":        "authenticaterequest_steam",
	"*server.AuthenticateRequest_GameCenter_":  "authenticaterequest_gamecenter",
	"*server.Envelope_Logout":                  "logout",
	"*server.Envelope_Link":                    "tlink",
	"*server.Envelope_Unlink":                  "tunlink",
	"*server.Envelope_SelfFetch":               "tselffetch",
	"*server.Envelope_SelfUpdate":              "tselfupdate",
	"*server.Envelope_UsersFetch":              "tusersfetch",
	"*server.Envelope_FriendsAdd":              "tfriendsadd",
	"*server.Envelope_FriendsRemove":           "tfriendsremove",
	"*server.Envelope_FriendsBlock":            "tfriendsblock",
	"*server.Envelope_FriendsList":             "tfriendslist",
	"*server.Envelope_GroupsCreate":            "tgroupscreate",
	"*server.Envelope_GroupsUpdate":            "tgroupsupdate",
	"*server.Envelope_GroupsRemove":            "tgroupsremove",
	"*server.Envelope_GroupsSelfList":          "tgroupsselflist",
	"*server.Envelope_GroupsFetch":             "tgroupsfetch",
	"*server.Envelope_GroupsList":              "tgroupslist",
	"*server.Envelope_GroupUsersList":          "tgroupuserslist",
	"*server.Envelope_GroupsJoin":              "tgroupsjoin",
	"*server.Envelope_GroupsLeave":             "tgroupsleave",
	"*server.Envelope_GroupUsersAdd":           "tgroupusersadd",
	"*server.Envelope_GroupUsersKick":          "tgroupuserskick",
	"*server.Envelope_GroupUsersPromote":       "tgroupuserspromote",
	"*server.Envelope_TopicsJoin":              "ttopicsjoin",
	"*server.Envelope_TopicsLeave":             "ttopicsleave",
	"*server.Envelope_TopicMessageSend":        "ttopicmessagesend",
	"*server.Envelope_TopicMessageAck":         "ttopicmessageack",
	"*server.Envelope_TopicMessagesList":       "ttopicmessageslist",
	"*server.Envelope_MatchmakeAdd":            "tmatchmakeadd",
	"*server.Envelope_MatchmakeTicket":         "tmatchmaketicket",
	"*server.Envelope_MatchmakeRemove":         "tmatchmakeremove",
	"*server.Envelope_MatchCreate":             "tmatchcreate",
	"*server.Envelope_MatchesJoin":             "tmatchesjoin",
	"*server.Envelope_MatchDataSend":           "matchdatasend",
	"*server.Envelope_MatchesLeave":            "tmatchesleave",
	"*server.Envelope_StorageList":             "tstoragelist",
	"*server.Envelope_StorageFetch":            "tstoragefetch",
	"*server.Envelope_StorageWrite":            "tstoragewrite",
	"*server.Envelope_StorageRemove":           "tstorageremove",
	"*server.Envelope_LeaderboardsList":        "tleaderboardslist",
	"*server.Envelope_LeaderboardRecordsWrite": "tleaderboardrecordswrite",
	"*server.Envelope_LeaderboardRecordsFetch": "tleaderboardrecordsfetch",
	"*server.Envelope_LeaderboardRecordsList":  "tleaderboardrecordslist",
	"*server.Envelope_Rpc":                     "trpc",
	"*server.Envelope_NotificationsList":       "tnotificationslist",
	"*server.Envelope_NotificationsRemove":     "tnotificationsremove",
}

Functions

func ConvertLuaTable added in v0.13.0

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

func ConvertMap added in v0.13.0

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

func GroupUsersList added in v1.0.0

func GroupUsersList(logger *zap.Logger, db *sql.DB, tracker Tracker, caller string, groupID string) ([]*GroupUser, Error_Code, error)

func GroupsSelfList added in v1.0.0

func GroupsSelfList(logger *zap.Logger, db *sql.DB, caller string, userID string) ([]*TGroupsSelf_GroupSelf, Error_Code, error)

func NewAuthenticationService

func NewAuthenticationService(logger *zap.Logger, config Config, db *sql.DB, jsonpbMarshaler *jsonpb.Marshaler, jsonpbUnmarshaler *jsonpb.Unmarshaler, statService StatsService, registry *SessionRegistry, socialClient *social.Client, pipeline *pipeline, runtimePool *RuntimePool) *authenticationService

NewAuthenticationService creates a new AuthenticationService

func NewConfig

func NewConfig() *config

NewConfig constructs a Config struct which represents server settings.

func NewConsoleLogger added in v0.12.2

func NewConsoleLogger(output *os.File, verbose bool) *zap.Logger

func NewDashboardService added in v1.0.0

func NewDashboardService(logger *zap.Logger, multiLogger *zap.Logger, version string, dbVersion string, config Config, statsService StatsService) *dashboardService

NewDashboardService creates a new dashboardService

func NewJSONLogger added in v0.12.2

func NewJSONLogger(output *os.File, verbose bool) *zap.Logger

func NewLogger added in v0.12.2

func NewLogger(config Config) *zap.Logger

func NewLuaContext added in v0.13.0

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

func NewMessageRouterService

func NewMessageRouterService(jsonpbMarshaler *jsonpb.Marshaler, registry *SessionRegistry) *messageRouterService

func NewMultiLogger added in v0.12.2

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

func NewPipeline

func NewPipeline(config Config,
	db *sql.DB,
	tracker Tracker,
	matchmaker Matchmaker,
	messageRouter MessageRouter,
	registry *SessionRegistry,
	socialClient *social.Client,
	runtimePool *RuntimePool,
	purchaseService *PurchaseService,
	notificationService *NotificationService) *pipeline

NewPipeline creates a new Pipeline

func NewPresenceNotifier

func NewPresenceNotifier(logger *zap.Logger, name string, tracker Tracker, messageRouter MessageRouter) *presenceNotifier

NewPresenceNotifier creates a new PresenceNotifier

func NewUDPSession added in v1.2.0

func NewUDPSession(logger *zap.Logger, config Config, userID string, handle string, lang string, expiry int64, clientInstance *multicode.ClientInstance, unregister func(s session)) session

NewUDPSession creates a new session which encapsulates a UDP client instance.

func NewWSSession added in v1.2.0

func NewWSSession(logger *zap.Logger, config Config, userID string, handle string, lang string, format SessionFormat, expiry int64, websocketConn *websocket.Conn, jsonpbMarshaler *jsonpb.Marshaler,
	jsonpbUnmarshaler *jsonpb.Unmarshaler, unregister func(s session)) session

NewWSSession creates a new session which encapsulates a WebSocket connection.

func OpenOs added in v0.13.0

func OpenOs(L *lua.LState) int

func RuntimeAfterHook added in v0.13.0

func RuntimeAfterHook(logger *zap.Logger, runtimePool *RuntimePool, jsonpbMarshaler *jsonpb.Marshaler, messageType string, envelope *Envelope, session session)

func RuntimeAfterHookAuthentication added in v0.13.0

func RuntimeAfterHookAuthentication(logger *zap.Logger, runtimePool *RuntimePool, jsonpbMarshaler *jsonpb.Marshaler, envelope *AuthenticateRequest, userId string, handle string, expiry int64)

func SetupLogging added in v1.0.0

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

func StorageFetch added in v0.13.0

func StorageFetch(logger *zap.Logger, db *sql.DB, caller string, keys []*StorageKey) ([]*StorageData, Error_Code, error)

func StorageList added in v1.0.0

func StorageList(logger *zap.Logger, db *sql.DB, caller string, userID string, bucket string, collection string, limit int64, cursor string) ([]*StorageData, string, Error_Code, error)

func StorageUpdate added in v1.0.0

func StorageUpdate(logger *zap.Logger, db *sql.DB, caller string, updates []*StorageKeyUpdate) ([]*StorageKey, Error_Code, error)

func StorageWrite added in v0.13.0

func StorageWrite(logger *zap.Logger, db *sql.DB, caller string, data []*StorageData) ([]*StorageKey, Error_Code, error)

func UsersBan added in v1.0.0

func UsersBan(logger *zap.Logger, db *sql.DB, userIds []string, handles []string) error

Types

type ApplePurchaseProviderConfig added in v1.0.0

type ApplePurchaseProviderConfig struct {
	Password   string `yaml:"password" json:"password" usage:"In-App Purchase password"`
	Production bool   `yaml:"production" json:"production" usage:"If set, the server will try Production environment then sandbox."`
	TimeoutMs  int    `yaml:"timeout_ms" json:"timeout_ms" usage:"Apple connection timeout in milliseconds"`
}

type BuiltinModule added in v0.13.0

type BuiltinModule interface {
	Loader(l *lua.LState) int
}

type Callbacks added in v0.13.0

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

type Cbuffer added in v1.1.0

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

func NewCbuffer added in v1.1.0

func NewCbuffer(maxSize int) *Cbuffer

type CbufferPool added in v1.1.0

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

func NewCbufferPool added in v1.1.0

func NewCbufferPool() *CbufferPool

type Config

type Config interface {
	GetName() string
	GetDataDir() string
	GetDashboard() *DashboardConfig
	GetLog() *LogConfig
	GetSession() *SessionConfig
	GetSocket() *SocketConfig
	GetDatabase() *DatabaseConfig
	GetSocial() *SocialConfig
	GetRuntime() *RuntimeConfig
	GetPurchase() *PurchaseConfig
}

Config interface is the Nakama Core configuration

func ParseArgs added in v1.0.0

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

type DashboardConfig added in v1.0.0

type DashboardConfig struct {
	Port int `yaml:"port" json:"port" usage:"The port for accepting connections to the dashboard, listening on all interfaces."`
}

DashboardConfig is configuration relevant to the dashboard

func NewDashboardConfig added in v1.0.0

func NewDashboardConfig() *DashboardConfig

NewSessionConfig creates a new SessionConfig struct

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 (
	RPC ExecutionMode = iota
	BEFORE
	AFTER
	HTTP
	JOB
	LEADERBOARD_RESET
)

func (ExecutionMode) String added in v0.13.0

func (e ExecutionMode) String() string

type Filter added in v1.1.0

type Filter int
const (
	BOOL Filter = iota
	RANGE
	TERM
)

type GooglePurchaseProviderConfig added in v1.0.0

type GooglePurchaseProviderConfig struct {
	PackageName        string `yaml:"package" json:"package" usage:"Android package name"`
	ServiceKeyFilePath string `yaml:"service_key_file" json:"service_key_file" usage:"Absolute file path to the service key JSON file."`
	TimeoutMs          int    `yaml:"timeout_ms" json:"timeout_ms" usage:"Google connection timeout in milliseconds"`
}

type GroupCreateParam added in v1.0.0

type GroupCreateParam struct {
	Name        string // mandatory
	Creator     string // mandatory
	Description string
	AvatarURL   string
	Lang        string
	Metadata    []byte
	Private     bool
}

type LogConfig added in v1.0.0

type LogConfig struct {
	Verbose bool `yaml:"verbose" json:"verbose" usage:"Turn verbose logging on"`
	Stdout  bool `yaml:"stdout" json:"stdout" usage:"Log to stdout instead of file"`
}

LogConfig is configuration relevant to logging levels and output

func NewLogConfig added in v1.0.0

func NewLogConfig() *LogConfig

NewLogConfig creates a new LogConfig struct

type Matchmaker added in v0.13.0

type Matchmaker interface {
	Add(sessionID string, userID string, requestProfile *MatchmakerProfile) (string, map[MatchmakerKey]*MatchmakerProfile, []*MatchmakerAcceptedProperty)
	Remove(sessionID string, userID string, ticket string) error
	RemoveAll(sessionID string)
	UpdateAll(sessionID string, meta PresenceMeta)
}

type MatchmakerAcceptedProperty added in v1.1.0

type MatchmakerAcceptedProperty struct {
	UserID     string
	Properties map[string]interface{}
	Filters    map[string]MatchmakerFilter
}

type MatchmakerBoolFilter added in v1.1.0

type MatchmakerBoolFilter struct {
	Value bool
}

func (*MatchmakerBoolFilter) Type added in v1.1.0

func (*MatchmakerBoolFilter) Type() Filter

type MatchmakerFilter added in v1.1.0

type MatchmakerFilter interface {
	Type() Filter
}

type MatchmakerKey added in v0.13.0

type MatchmakerKey struct {
	ID     PresenceID
	UserID string
	Ticket string
}

type MatchmakerProfile added in v0.13.0

type MatchmakerProfile struct {
	Meta          PresenceMeta
	RequiredCount int
	Properties    map[string]interface{}
	Filters       map[string]MatchmakerFilter
}

type MatchmakerRangeFilter added in v1.1.0

type MatchmakerRangeFilter struct {
	LowerBound int64
	UpperBound int64
}

func (*MatchmakerRangeFilter) Type added in v1.1.0

func (*MatchmakerRangeFilter) Type() Filter

type MatchmakerService added in v0.13.0

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

func NewMatchmakerService added in v0.13.0

func NewMatchmakerService(name string) *MatchmakerService

func (*MatchmakerService) Add added in v0.13.0

func (m *MatchmakerService) Add(sessionID string, userID string, incomingProfile *MatchmakerProfile) (string, map[MatchmakerKey]*MatchmakerProfile, []*MatchmakerAcceptedProperty)

func (*MatchmakerService) Remove added in v0.13.0

func (m *MatchmakerService) Remove(sessionID string, userID string, ticket string) error

func (*MatchmakerService) RemoveAll added in v0.13.0

func (m *MatchmakerService) RemoveAll(sessionID string)

func (*MatchmakerService) UpdateAll added in v0.13.0

func (m *MatchmakerService) UpdateAll(sessionID string, meta PresenceMeta)

type MatchmakerTermFilter added in v1.1.0

type MatchmakerTermFilter struct {
	Terms    []string
	AllTerms bool // set to False for Any Term
}

func (*MatchmakerTermFilter) Type added in v1.1.0

func (*MatchmakerTermFilter) Type() Filter

type MessageRouter

type MessageRouter interface {
	Send(*zap.Logger, []Presence, proto.Message, bool)
}

MessageRouter is responsible for sending a message to a list of presences

type NNotification added in v1.0.0

type NNotification struct {
	Id         string
	UserID     string
	Subject    string
	Content    []byte
	Code       int64
	SenderID   string
	CreatedAt  int64
	ExpiresAt  int64
	Persistent bool
}

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, l *lua.LState, tracker Tracker, notificationService *NotificationService, cbufferPool *CbufferPool, announceHTTP func(string), announceRPC func(string), announceBefore func(string), announceAfter func(string)) *NakamaModule

func (*NakamaModule) Loader added in v0.13.0

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

type NotificationConfig added in v1.0.0

type NotificationConfig struct {
	ExpiryMs int64 `yaml:"expiry_ms" json:"expiry_ms" usage:"Notification expiry in milliseconds."`
}

NotificationConfig is configuration relevant to notification center

type NotificationService added in v1.0.0

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

func NewNotificationService added in v1.0.0

func NewNotificationService(logger *zap.Logger, db *sql.DB, tracker Tracker, messageRouter MessageRouter, config *NotificationConfig) *NotificationService

func (*NotificationService) NotificationSend added in v1.0.0

func (n *NotificationService) NotificationSend(notifications []*NNotification) error

func (*NotificationService) NotificationsList added in v1.0.0

func (n *NotificationService) NotificationsList(userID string, limit int64, cursor string) ([]*NNotification, string, error)

func (*NotificationService) NotificationsRemove added in v1.0.0

func (n *NotificationService) NotificationsRemove(userID string, notificationIDs []string) error

type Presence

type Presence struct {
	ID     PresenceID
	Topic  string
	UserID string
	Meta   PresenceMeta
}

type PresenceID

type PresenceID struct {
	Node      string
	SessionID string
}

type PresenceMeta

type PresenceMeta struct {
	Handle string
	Format SessionFormat
}

type PurchaseConfig added in v1.0.0

type PurchaseConfig struct {
	Apple  *ApplePurchaseProviderConfig  `yaml:"apple" json:"apple" usage:"Apple In-App Purchase configuration"`
	Google *GooglePurchaseProviderConfig `yaml:"google" json:"google" usage:"Google In-App Purchase configuration"`
}

PurchaseConfig is configuration relevant to the In-App Purchase providers.

func NewPurchaseConfig added in v1.0.0

func NewPurchaseConfig() *PurchaseConfig

NewPurchaseConfig creates a new PurchaseConfig struct

type PurchaseService added in v1.0.0

type PurchaseService struct {
	AppleClient  *iap.AppleClient
	GoogleClient *iap.GoogleClient
	// contains filtered or unexported fields
}

func NewPurchaseService added in v1.0.0

func NewPurchaseService(jsonLogger *zap.Logger, multiLogger *zap.Logger, db *sql.DB, config *PurchaseConfig) *PurchaseService

func (*PurchaseService) ValidateApplePurchase added in v1.0.0

func (p *PurchaseService) ValidateApplePurchase(userID string, purchase *iap.ApplePurchase) *iap.PurchaseVerifyResponse

func (*PurchaseService) ValidateGooglePurchaseProduct added in v1.0.0

func (p *PurchaseService) ValidateGooglePurchaseProduct(userID string, purchase *iap.GooglePurchase) *iap.PurchaseVerifyResponse

func (*PurchaseService) ValidateGooglePurchaseSubscription added in v1.0.0

func (p *PurchaseService) ValidateGooglePurchaseSubscription(userID string, purchase *iap.GooglePurchase) *iap.PurchaseVerifyResponse

type Runtime added in v0.13.0

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

func (*Runtime) GetRuntimeCallback added in v0.13.0

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

func (*Runtime) InvokeFunctionAfter added in v0.13.0

func (r *Runtime) InvokeFunctionAfter(fn *lua.LFunction, uid string, handle string, sessionExpiry int64, payload map[string]interface{}) error

func (*Runtime) InvokeFunctionBefore added in v0.13.0

func (r *Runtime) InvokeFunctionBefore(fn *lua.LFunction, uid string, handle string, sessionExpiry int64, jsonpbMarshaler *jsonpb.Marshaler, jsonpbUnmarshaler *jsonpb.Unmarshaler, envelope *Envelope) (*Envelope, error)

func (*Runtime) InvokeFunctionBeforeAuthentication added in v1.0.1

func (r *Runtime) InvokeFunctionBeforeAuthentication(fn *lua.LFunction, uid string, handle string, sessionExpiry int64, payload map[string]interface{}) (map[string]interface{}, error)

func (*Runtime) InvokeFunctionHTTP added in v0.13.0

func (r *Runtime) InvokeFunctionHTTP(fn *lua.LFunction, uid string, handle string, sessionExpiry int64, payload map[string]interface{}) (map[string]interface{}, error)

func (*Runtime) InvokeFunctionRPC added in v0.13.0

func (r *Runtime) InvokeFunctionRPC(fn *lua.LFunction, uid string, handle string, sessionExpiry int64, payload string) (string, error)

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{} `yaml:"env" json:"env"` // not supported in FlagOverrides
	Path        string                 `yaml:"path" json:"path" usage:"Path of modules for the server to scan."`
	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 {
	// contains filtered or unexported fields
}

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, multiLogger *zap.Logger, db *sql.DB, config *RuntimeConfig, tracker Tracker, notificationService *NotificationService) (*RuntimePool, error)

func (*RuntimePool) Get added in v1.1.0

func (rp *RuntimePool) Get() *Runtime

func (*RuntimePool) HasAfter added in v1.2.0

func (rp *RuntimePool) HasAfter(messageName string) bool

func (*RuntimePool) HasBefore added in v1.2.0

func (rp *RuntimePool) HasBefore(messageName string) bool

func (*RuntimePool) HasHTTP added in v1.2.0

func (rp *RuntimePool) HasHTTP(path string) bool

func (*RuntimePool) HasRPC added in v1.2.0

func (rp *RuntimePool) HasRPC(id string) bool

func (*RuntimePool) Put added in v1.1.0

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

type SelfUpdateOp added in v1.0.0

type SelfUpdateOp struct {
	UserId    string
	Handle    string
	Fullname  string
	Timezone  string
	Location  string
	Lang      string
	Metadata  []byte
	AvatarUrl string
}

type SessionConfig

type SessionConfig struct {
	EncryptionKey string `yaml:"encryption_key" json:"encryption_key" usage:"The encryption key used to produce the client token."`
	UdpKey        string `yaml:"udp_key" json:"udp_key" usage:"The UDP key used to produce the raw UDP connection token."`
	TokenExpiryMs int64  `yaml:"token_expiry_ms" json:"token_expiry_ms" usage:"Token expiry in milliseconds."`
}

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 int
const (
	SessionFormatProtobuf SessionFormat = 0
	SessionFormatJson                   = 1
)

type SessionRegistry

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

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

func NewSessionRegistry

func NewSessionRegistry(logger *zap.Logger, config Config, tracker Tracker, matchmaker Matchmaker) *SessionRegistry

NewSessionRegistry creates a new SessionRegistry

func (*SessionRegistry) Get

func (a *SessionRegistry) Get(sessionID string) session

Get returns a session matching the sessionID

type SocialConfig

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

SocialConfig is configuration relevant to the Social 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."`
	ListenAddress       string `yaml:"listen_address" json:"listen_address" usage:"IP address to listen for traffic on."`
	PublicAddress       string `yaml:"public_address" json:"public_address" usage:"IP address to advertise to clients."`
	Port                int    `yaml:"port" json:"port" usage:"The port for accepting connections from the client, listening on all interfaces."`
	MaxMessageSizeBytes int64  `` /* 154-byte string literal not displayed */
	WriteWaitMs         int    `yaml:"write_wait_ms" json:"write_wait_ms" usage:"Time in milliseconds to wait for an ack from the client when writing data."`
	PongWaitMs          int    `` /* 133-byte string literal not displayed */
	PingPeriodMs        int    `` /* 157-byte string literal not displayed */
}

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 StatsService

type StatsService interface {
	GetStats() []map[string]interface{}
	GetHealthStatus() int
}

StatsService is responsible for gathering and reading stats information from metrics

func NewStatsService

func NewStatsService(logger *zap.Logger, config Config, version string, tracker Tracker, startedAt int64) StatsService

NewStatsService creates a new StatsService

type StorageData added in v0.13.0

type StorageData struct {
	Bucket          string
	Collection      string
	Record          string
	UserId          string // this must be UserId not UserID
	Value           []byte
	Version         string
	PermissionRead  int64
	PermissionWrite int64
	CreatedAt       int64
	UpdatedAt       int64
	ExpiresAt       int64
}

type StorageKey added in v0.13.0

type StorageKey struct {
	Bucket     string
	Collection string
	Record     string
	UserId     string // this must be UserId not UserID
	// Version is used when returning results from write ops, does not apply to fetch ops.
	Version string
}

type StorageKeyUpdate added in v1.0.0

type StorageKeyUpdate struct {
	Key             *StorageKey
	PermissionRead  int64
	PermissionWrite int64
	Patch           jsonpatch.ExtendedPatch
}

type Tracker

type Tracker interface {
	AddDiffListener(func([]Presence, []Presence))
	Stop()

	// Track a presence. Returns `true` if it was a new presence, `false` otherwise.
	Track(sessionID string, topic string, userID string, meta PresenceMeta) bool
	Untrack(sessionID string, topic string, userID string)
	UntrackAll(sessionID string)
	Update(sessionID string, topic string, userID string, meta PresenceMeta) error
	UpdateAll(sessionID string, meta PresenceMeta)

	// Get current total number of presences.
	Count() int
	// Check if a single presence on the current node exists.
	CheckLocalByIDTopicUser(sessionID string, topic string, userID string) bool
	// List presences by topic.
	ListByTopic(topic string) []Presence
	// List presences on the current node by topic.
	ListLocalByTopic(topic string) []Presence
	// List presences by topic and user ID.
	ListByTopicUser(topic string, userID string) []Presence
}

type TrackerService

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

func NewTrackerService

func NewTrackerService(name string) *TrackerService

func (*TrackerService) AddDiffListener

func (t *TrackerService) AddDiffListener(f func([]Presence, []Presence))

func (*TrackerService) CheckLocalByIDTopicUser

func (t *TrackerService) CheckLocalByIDTopicUser(sessionID string, topic string, userID string) bool

func (*TrackerService) Count

func (t *TrackerService) Count() int

func (*TrackerService) ListByTopic

func (t *TrackerService) ListByTopic(topic string) []Presence

func (*TrackerService) ListByTopicUser added in v1.0.0

func (t *TrackerService) ListByTopicUser(topic string, userID string) []Presence

func (*TrackerService) ListLocalByTopic

func (t *TrackerService) ListLocalByTopic(topic string) []Presence

func (*TrackerService) Stop

func (t *TrackerService) Stop()

func (*TrackerService) Track

func (t *TrackerService) Track(sessionID string, topic string, userID string, meta PresenceMeta) bool

func (*TrackerService) Untrack

func (t *TrackerService) Untrack(sessionID string, topic string, userID string)

func (*TrackerService) UntrackAll

func (t *TrackerService) UntrackAll(sessionID string)

func (*TrackerService) Update

func (t *TrackerService) Update(sessionID string, topic string, userID string, meta PresenceMeta) error

func (*TrackerService) UpdateAll added in v0.12.0

func (t *TrackerService) UpdateAll(sessionID string, meta PresenceMeta)

Jump to

Keyboard shortcuts

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