gen_room

package
v0.0.0-...-8d9cb7d Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	RcvGroup_Others byte = 0
	RcvGroup_All         = 1
	RcvGroup_Master      = 2
)

Variables

This section is empty.

Functions

func AddPeer

func AddPeer(peer *RoomPeer) error

func BindEventCallback

func BindEventCallback(eventer IGenRoomEventer)

func ClrEventCache

func ClrEventCache(roomId string, peerId string) error

func CreateRoom

func CreateRoom(peerId string, roomId string, lobbyId string, maxPeers byte) (*RoomEntity, *Actor, error)

func DisposeRoom

func DisposeRoom(roomId string) error

func GetActorInRoom

func GetActorInRoom(peerId string, roomId string) (*RoomEntity, *Actor, error)

func InitGameDB

func InitGameDB(mongoConf string) error

func JoinRoom

func JoinRoom(peerId string, roomId string) (*RoomEntity, *Actor, error)

func LeaveRoom

func LeaveRoom(peerId string, roomId string) (*RoomEntity, *Actor, error)

func RaiseEvent

func RaiseEvent(peerId string, roomId string, data []byte, rcvGroup byte, addToRoomCache bool) error

func RcvCacheEvent

func RcvCacheEvent(peerId string, roomId string) error

func RemovePeer

func RemovePeer(peerId string) error

Types

type Actor

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

func NewActor

func NewActor(peerId string, actorNr int32) *Actor

func (*Actor) ActorNr

func (a *Actor) ActorNr() int32

func (*Actor) PeerId

func (a *Actor) PeerId() string

type ActorsManager

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

func NewActorsManager

func NewActorsManager() *ActorsManager

func (*ActorsManager) ActorsCount

func (a *ActorsManager) ActorsCount() int

func (*ActorsManager) AddNewActor

func (a *ActorsManager) AddNewActor(peerId string) (*Actor, error)

func (*ActorsManager) ClearAll

func (a *ActorsManager) ClearAll()

func (*ActorsManager) CreateActorNr

func (a *ActorsManager) CreateActorNr() int32

func (*ActorsManager) GetActorByIndex

func (a *ActorsManager) GetActorByIndex(index int) (*Actor, bool)

func (*ActorsManager) GetActorByNr

func (a *ActorsManager) GetActorByNr(actorNr int32) (*Actor, bool)

func (*ActorsManager) GetActorByPeerId

func (a *ActorsManager) GetActorByPeerId(peerId string) (*Actor, bool)

func (*ActorsManager) GetAllActorNrs

func (a *ActorsManager) GetAllActorNrs() []int32

func (*ActorsManager) GetAllPeerIds

func (a *ActorsManager) GetAllPeerIds() []string

func (*ActorsManager) RemoveActorByNr

func (a *ActorsManager) RemoveActorByNr(actorNr int32) (*Actor, bool)

func (*ActorsManager) RemoveActorByPeer

func (a *ActorsManager) RemoveActorByPeer(peerId string) (*Actor, bool)

type EventCacheManager

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

func NewEventCacheManager

func NewEventCacheManager() *EventCacheManager

func (*EventCacheManager) AddEvent

func (e *EventCacheManager) AddEvent(actor int32, data []byte)

func (*EventCacheManager) ClearCache

func (e *EventCacheManager) ClearCache()

func (*EventCacheManager) Events

func (e *EventCacheManager) Events() []interface{}

func (*EventCacheManager) RemoveEventsByActor

func (e *EventCacheManager) RemoveEventsByActor(actor int32) int

type EventData

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

func NewEventData

func NewEventData(actor int32, data []byte) *EventData

func (*EventData) ActorNr

func (e *EventData) ActorNr() int32

func (*EventData) Data

func (e *EventData) Data() []byte

type IGenRoomEventer

type IGenRoomEventer interface {
	OnJoinRoom(actor *Actor, room *RoomEntity)
	OnLeaveRoom(actor *Actor, room *RoomEntity)
	OnCustomEvent(actor *Actor, room *RoomEntity, data []byte)
}

type ListInt

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

func NewListInt

func NewListInt(capacity int) *ListInt

func NewListIntRaw

func NewListIntRaw(raw []int32) *ListInt

func (*ListInt) Add

func (l *ListInt) Add(item int32)

func (*ListInt) Capacity

func (l *ListInt) Capacity() int

func (*ListInt) Clear

func (l *ListInt) Clear()

func (*ListInt) Contains

func (l *ListInt) Contains(item int32) bool

func (*ListInt) Count

func (l *ListInt) Count() int

func (*ListInt) ForEach

func (l *ListInt) ForEach(fun func(int32))

func (*ListInt) Get

func (l *ListInt) Get(index int) (int32, error)

func (*ListInt) IndexOf

func (l *ListInt) IndexOf(item int32) int

func (*ListInt) Insert

func (l *ListInt) Insert(index int, item int32) error

func (*ListInt) Items

func (l *ListInt) Items() []int32

func (*ListInt) Remove

func (l *ListInt) Remove(item int32) bool

func (*ListInt) RemoveAt

func (l *ListInt) RemoveAt(index int) error

func (*ListInt) Set

func (l *ListInt) Set(index int, item int32) error

type LiteRoomEntity

type LiteRoomEntity struct {
	RoomId    string            `bson:"roomid"`
	Nick      string            `bson:"nick"`
	LobbyId   string            `bson:"lobbyid"`
	NodeId    string            `bson:"nodeid"`
	PeerCount int               `bson:"peercount"`
	MaxPeers  int               `bson:"maxpeers"`
	UsrDatas  map[string]string `bson:"usrdatas"`
}

type RoomEntity

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

func NewRoomEntity

func NewRoomEntity(roomId string, lobbyId string, maxPeers byte) *RoomEntity

func NewRoomEntityFromLite

func NewRoomEntityFromLite(lite *LiteRoomEntity) *RoomEntity

func (*RoomEntity) ActorsManager

func (r *RoomEntity) ActorsManager() *ActorsManager

func (*RoomEntity) EventCache

func (r *RoomEntity) EventCache() *EventCacheManager

func (*RoomEntity) IsEmpty

func (r *RoomEntity) IsEmpty() bool

func (*RoomEntity) IsFull

func (r *RoomEntity) IsFull() bool

func (*RoomEntity) LobbyId

func (r *RoomEntity) LobbyId() string

func (*RoomEntity) MasterId

func (r *RoomEntity) MasterId() int32

func (*RoomEntity) MaxPeers

func (r *RoomEntity) MaxPeers() byte

func (*RoomEntity) Nick

func (r *RoomEntity) Nick() string

func (*RoomEntity) PeerCount

func (r *RoomEntity) PeerCount() byte

func (*RoomEntity) RoomId

func (r *RoomEntity) RoomId() string

func (*RoomEntity) SetMasterId

func (r *RoomEntity) SetMasterId(masterId int32)

func (*RoomEntity) SetNick

func (r *RoomEntity) SetNick(nick string)

func (*RoomEntity) UpdateStatusToGameDB

func (r *RoomEntity) UpdateStatusToGameDB() error

type RoomManager

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

func NewRoomManager

func NewRoomManager() *RoomManager

func (*RoomManager) CreateRoom

func (r *RoomManager) CreateRoom(roomId string, lobbyId string, maxPeers byte) (*RoomEntity, error)

func (*RoomManager) DisposeRoom

func (r *RoomManager) DisposeRoom(roomId string)

func (*RoomManager) FetchRoom

func (r *RoomManager) FetchRoom(roomId string, lobbyId string, maxPeers byte) *RoomEntity

func (*RoomManager) FindRoom

func (r *RoomManager) FindRoom(roomId string) (*RoomEntity, error)

type RoomPeer

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

func GetPeer

func GetPeer(peerId string) (*RoomPeer, bool)

func NewRoomPeer

func NewRoomPeer(peerId string) *RoomPeer

func (*RoomPeer) PeerId

func (r *RoomPeer) PeerId() string

func (*RoomPeer) RoomId

func (r *RoomPeer) RoomId() string

func (*RoomPeer) SetRoomId

func (r *RoomPeer) SetRoomId(roomId string)

type RoomServerInfo

type RoomServerInfo struct {
	RegDC     string
	NameSpace string
	NodeId    string
	EndPoints []string
	GameDB    string
	PubDomain string
}

func (*RoomServerInfo) ExpandToNodeInfo

func (serverInfo *RoomServerInfo) ExpandToNodeInfo() *gen_server.NodeInfo

Jump to

Keyboard shortcuts

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