session

package
Version: v0.0.0-...-de75733 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func GetTimeStamp

func GetTimeStamp() int64

func NewEntityState

func NewEntityState(id int64, prefabName string, c *Character) *EntityState

Types

type ChatMessage

type ChatMessage struct {
	SpeakerId   int32
	SpeakerName string
	Content     string
}

type ChatRoom

type ChatRoom struct {
	ReadingBuffer []*ChatMessage
}

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 Room

type Room struct {
	Name      string
	GameType  string
	Master    *Session
	Client    map[*Session]struct{}
	Uuid      int64
	GameFrame *GameFrame
	*MsgChannelManager
	sync.RWMutex
	GameStart chan (struct{})
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(roomId int64) *Room

func (*Room) GenerateStartFrame

func (r *Room) GenerateStartFrame()

func (*Room) HandleEntityDestory

func (r *Room) HandleEntityDestory(input *Input)

func (*Room) HandleEntityState

func (r *Room) HandleEntityState(input *Input)

func (*Room) HandleInteraction

func (r *Room) HandleInteraction(input *Input)

func (*Room) HandleNewEntity

func (r *Room) HandleNewEntity(input *Input)

func (*Room) PlayerLeave

func (r *Room) PlayerLeave(s *Session)

func (*Room) Run

func (r *Room) Run()

func (*Room) SyncGameFrame

func (r *Room) SyncGameFrame()

func (*Room) UpdateFrame

func (r *Room) UpdateFrame()

func (*Room) WaitPlayerReconnect

func (r *Room) WaitPlayerReconnect(s *Session)

type Session

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

func NewSession

func NewSession(info *SessionInfo) *Session

func (*Session) GetPlayerInfo

func (s *Session) GetPlayerInfo() *PlayerInfo

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()
	HandleInput(input *Input)
	Unlock()
	StartGame()
	Reconnect()
	EndConnection()
	WaitReconnect()
	End()
}

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) End

func (sb *SessionStateBase) End()

func (*SessionStateBase) EndConnection

func (sb *SessionStateBase) EndConnection()

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) HandleInput

func (sb *SessionStateBase) HandleInput(input *Input)

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) Reconnect

func (sb *SessionStateBase) Reconnect()

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) StartGame

func (sb *SessionStateBase) StartGame()

func (*SessionStateBase) StartRoom

func (sb *SessionStateBase) StartRoom() bool

func (*SessionStateBase) String

func (sb *SessionStateBase) String() string

func (*SessionStateBase) WaitReconnect

func (sb *SessionStateBase) WaitReconnect()

type SessionStateGameOnStart

type SessionStateGameOnStart struct {
	SessionStateBase
}

func (*SessionStateGameOnStart) StartGame

func (ssgos *SessionStateGameOnStart) StartGame()

type SessionStateGameOver

type SessionStateGameOver struct {
	SessionStateBase
}

func (*SessionStateGameOver) End

func (ssgo *SessionStateGameOver) End()

type SessionStatePlaying

type SessionStatePlaying struct {
	SessionStateBase
}

func (*SessionStatePlaying) EndConnection

func (sb *SessionStatePlaying) EndConnection()

func (*SessionStatePlaying) HandleInput

func (sb *SessionStatePlaying) HandleInput(input *Input)

func (*SessionStatePlaying) WaitReconnect

func (sb *SessionStatePlaying) WaitReconnect()

type SessionStateWaitingReconnection

type SessionStateWaitingReconnection struct {
	SessionStateBase
}

func (*SessionStateWaitingReconnection) EndConnection

func (sswr *SessionStateWaitingReconnection) EndConnection()

func (*SessionStateWaitingReconnection) Reconnect

func (sswr *SessionStateWaitingReconnection) Reconnect()

func (*SessionStateWaitingReconnection) StartGame

func (sswr *SessionStateWaitingReconnection) StartGame()

func (*SessionStateWaitingReconnection) Waiting

func (sswr *SessionStateWaitingReconnection) Waiting()

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto