session

package
v0.0.0-...-620f6c9 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_PORT int = 31000
View Source
const MAX_ROOM_IN_POD = 1

MAX_ROOM_IN_POD maxium rooms in pod

View Source
const MAX_SERVER_AMOUT int = 20
View Source
const MIN_PORT int = 30000
View Source
const NAME_SPACE string = "default"
View Source
const SERVER_AMOUNT int = 1

Variables

View Source
var ClusterManager *clusterManager

ClusterManager clustermanager's instance

View Source
var Manager *sessionManager
View Source
var PodMod *v1.Pod
View Source
var RoomManager *roomManager = &roomManager{
	Rooms:                make(map[int64]*Room),
	UserIdleRoomListChan: make(map[*MsgChannel]struct{}),
	GameServers:          make(map[*GameServer]struct{}),
}
View Source
var SessionStateFactory *sessionStateFactory

Functions

This section is empty.

Types

type ChatMessage

type ChatMessage struct {
	SpeakerId   int32
	SpeakerName string
	Content     string
}

type ChatRoom

type ChatRoom struct {
	ReadingBuffer []*ChatMessage
}

type ConnectingGameSessionState

type ConnectingGameSessionState struct {
	SessionStateBase
}

func (*ConnectingGameSessionState) EndRoom

func (ss *ConnectingGameSessionState) EndRoom() bool

type GameServer

type GameServer struct {
	ExtIp      string
	AgentPort  string
	ClientPort string
	Client     AgentToGameClient
	Rooms      map[*Room]struct{}
	// contains filtered or unexported fields
}

type GuestSessionState

type GuestSessionState struct {
	SessionStateBase
}

func (*GuestSessionState) Login

func (ss *GuestSessionState) Login(uname string, pswd string) *user.User

func (*GuestSessionState) Regist

func (ss *GuestSessionState) Regist(uname string, pswd string, info ...string) bool

type MsgChannel

type MsgChannel struct {
	DataCh     chan (interface{})
	StopSignal chan (struct{})
}

func NewMsgChannel

func NewMsgChannel(bufferNumber int32) *MsgChannel

func (*MsgChannel) Close

func (m *MsgChannel) Close()

type MsgChannelManager

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

func NewMsgChannelManager

func NewMsgChannelManager() *MsgChannelManager

func (*MsgChannelManager) AddMsgChan

func (m *MsgChannelManager) AddMsgChan(name string, bufferNumber int32) bool

func (*MsgChannelManager) CloseMsgChan

func (m *MsgChannelManager) CloseMsgChan(name string)

func (*MsgChannelManager) GetMsgChan

func (m *MsgChannelManager) GetMsgChan(name string) *MsgChannel

type NoSessionState

type NoSessionState struct {
	SessionStateBase
}

func (*NoSessionState) CreateSession

func (ss *NoSessionState) CreateSession() int64

type Room

type Room struct {
	Name                string
	GameType            string
	Master              *Session
	Client              map[*Session]struct{}
	Uuid                int64
	IsFull              bool
	IsCreatOnGameServer bool
	MaxPlyer            int32
	PlayerInRoom        int32
	Review              *RoomReview
	GameServer          *GameServer
	sync.RWMutex
}

func NewRoom

func NewRoom(master *Session, roomId int64, setting *RoomSetting) *Room

func (*Room) CheckReady

func (r *Room) CheckReady() bool

func (*Room) CreateRoomOnGameServer

func (r *Room) CreateRoomOnGameServer()

func (*Room) DeleteRoom

func (r *Room) DeleteRoom() bool

func (*Room) EnterRoom

func (r *Room) EnterRoom(client *Session) bool

func (*Room) GetReview

func (r *Room) GetReview() (Review *RoomReview)

func (*Room) KickOut

func (r *Room) KickOut(master *Session, client *Session) bool

func (*Room) LeaveRoom

func (r *Room) LeaveRoom(s *Session) bool

func (*Room) UpdateReview

func (r *Room) UpdateReview()

func (*Room) UpdateRoomContent

func (r *Room) UpdateRoomContent()

type Session

type Session struct {
	Info       *SessionInfo
	State      SessionState
	SessionKey int64
	User       *user.User
	States     []SessionState
	Room       *Room
	*MsgChannelManager
	sync.RWMutex
	PlayerInfo *PlayerInfo
	TeamNo     int32
	IsReady    bool
	ServerInfo *ServerInfo
}

func NewSession

func NewSession() *Session

func (*Session) GetPlayerInfo

func (s *Session) GetPlayerInfo() *PlayerInfo

func (*Session) GetSessionCache

func (s *Session) GetSessionCache() *SessionCache

func (*Session) GetSessionInfo

func (s *Session) GetSessionInfo() *SessionInfo

func (*Session) SetState

func (s *Session) SetState(state_index int32)

type SessionState

type SessionState interface {
	SetSession(s *Session) bool
	SetStateCode(SessionInfo_SessionState)
	GetStateCode() SessionInfo_SessionState
	CreateSession() int64
	Login(uname string, pswd string) *user.User
	Logout() bool
	Regist(uname string, pswd string, info ...string) bool
	CreateRoom(setting *RoomSetting) bool
	EnterRoom(roomId int64) bool
	DeleteRoom() bool
	ReadyRoom() bool
	LeaveRoom() bool
	StartRoom() bool
	SettingCharacter(*CharacterSetting) bool
	SettingRoom() bool
	CancelReady() bool
	EndRoom() bool
	String() string
	Lock()
	Unlock()
}

type SessionStateBase

type SessionStateBase struct {
	StateCode SessionInfo_SessionState
	Session   *Session
	sync.RWMutex
}

func (*SessionStateBase) CancelReady

func (sb *SessionStateBase) CancelReady() bool

func (*SessionStateBase) CreateRoom

func (sb *SessionStateBase) CreateRoom(setting *RoomSetting) bool

func (*SessionStateBase) CreateSession

func (sb *SessionStateBase) CreateSession() int64

func (*SessionStateBase) DeleteRoom

func (sb *SessionStateBase) DeleteRoom() bool

func (*SessionStateBase) EndRoom

func (sb *SessionStateBase) EndRoom() bool

func (*SessionStateBase) EnterRoom

func (sb *SessionStateBase) EnterRoom(roomId int64) bool

func (*SessionStateBase) GetStateCode

func (sb *SessionStateBase) GetStateCode() SessionInfo_SessionState

func (*SessionStateBase) LeaveRoom

func (sb *SessionStateBase) LeaveRoom() bool

func (*SessionStateBase) Login

func (sb *SessionStateBase) Login(uname string, pswd string) *user.User

func (*SessionStateBase) Logout

func (sb *SessionStateBase) Logout() bool

func (*SessionStateBase) ReadyRoom

func (sb *SessionStateBase) ReadyRoom() bool

func (*SessionStateBase) Regist

func (sb *SessionStateBase) Regist(uname string, pswd string, info ...string) bool

func (*SessionStateBase) SetSession

func (sb *SessionStateBase) SetSession(s *Session) bool

func (*SessionStateBase) SetStateCode

func (sb *SessionStateBase) SetStateCode(code SessionInfo_SessionState)

func (*SessionStateBase) SettingCharacter

func (sb *SessionStateBase) SettingCharacter(*CharacterSetting) bool

func (*SessionStateBase) SettingRoom

func (sb *SessionStateBase) SettingRoom() bool

func (*SessionStateBase) StartRoom

func (sb *SessionStateBase) StartRoom() bool

func (*SessionStateBase) String

func (sb *SessionStateBase) String() string

type UserIdleSessionState

type UserIdleSessionState struct {
	SessionStateBase
}

func (*UserIdleSessionState) CreateRoom

func (ss *UserIdleSessionState) CreateRoom(roomSetting *RoomSetting) bool

func (*UserIdleSessionState) EnterRoom

func (ss *UserIdleSessionState) EnterRoom(roomId int64) bool

type UserInRoomSessionState

type UserInRoomSessionState struct {
	SessionStateBase
}

func (*UserInRoomSessionState) CancelReady

func (ss *UserInRoomSessionState) CancelReady() bool

func (*UserInRoomSessionState) DeleteRoom

func (ss *UserInRoomSessionState) DeleteRoom() bool

func (*UserInRoomSessionState) LeaveRoom

func (ss *UserInRoomSessionState) LeaveRoom() bool

func (*UserInRoomSessionState) ReadyRoom

func (ss *UserInRoomSessionState) ReadyRoom() bool

func (*UserInRoomSessionState) SettingCharacter

func (ss *UserInRoomSessionState) SettingCharacter(setting *CharacterSetting) bool

Jump to

Keyboard shortcuts

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