area

package
v0.0.0-...-bf94cd9 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllConns *syncmap.SyncMap

所有的用户连接对象

View Source
var AllWsConns *syncmap.SyncMap
View Source
var Areas = make([]string, 0, 1000)

所有的场景名称列表

View Source
var AreasMap *syncmap.SyncMap

场景集合

View Source
var UserJoinedAreas *syncmap.SyncMap

用户加入过的场景列表

Functions

func AddSid

func AddSid(sid string, area_id string) bool

func Broatcast

func Broatcast(sid string, area_id string, msg []byte)

*

  • 在场景中广播消息

func BroatcastGlobal

func BroatcastGlobal(sid string, msg []byte)

*

  • 在场景中广播消息

func CheckExist

func CheckExist(area_id string) bool

检查是否已经创建了场景

func CheckSid

func CheckSid(sid string) bool

*

  • 检查

func CheckUserJoined

func CheckUserJoined(area_id string, sid string) bool

*

  • 检查用户是否加入到场景中

func ConnRegister

func ConnRegister(conn *net.TCPConn, sid string)

func Create

func Create(area_id string, name string)

创建一个场景

func CreateSid

func CreateSid() string

func DeleteConn

func DeleteConn(sid string)

func DeleteSession

func DeleteSession(sid string)

func DeleteUserJoinedAreas

func DeleteUserJoinedAreas(sid string)

func DeleteUserssion

func DeleteUserssion(sid string)

func DeleteWsConn

func DeleteWsConn(sid string)

func FreeConn

func FreeConn(conn *net.TCPConn, sid string)

func FreeWsConn

func FreeWsConn(ws *websocket.Conn, sid string)

func GetConn

func GetConn(sid string) *net.TCPConn

func GetSids

func GetSids(area_id string) []string

func GetWsConn

func GetWsConn(sid string) *websocket.Conn

func Gets

func Gets() map[string]string

获取场景列表

func InitConfig

func InitConfig()

预创建多个场景

func Push

func Push(to_sid string, from_sid string, to_data []byte)

*

  • 点对点发送消息

func Remove

func Remove(id string)

删除一个场景

func Subscribe

func Subscribe(area_id string, conn *net.TCPConn, sid string)

*

  • socket连接 加入到场景中

func UnSubGlobal

func UnSubGlobal(sid string)

func UnSubscribe

func UnSubscribe(area_id string, sid string)

*

  • 用户退出某个场景

func UserUnSubscribe

func UserUnSubscribe(user_sid string)

用户退出所有场景

func WsConnRegister

func WsConnRegister(ws *websocket.Conn, user_sid string)

func WsSubscribe

func WsSubscribe(area_id string, ws *websocket.Conn, sid string)

*

  • websocket连接 加入到场景中

Types

type AreaType

type AreaType struct {
	// 唯一标识符
	Id string
	// 场景名称
	Name string
	// 当前场景包含的socket连接对象
	Conns *syncmap.SyncMap
	// 当前场景包含的websocket连接对象
	WsConns *syncmap.SyncMap

	CreateTime int64
}
var GlobalArea *AreaType

一个全局的场景

func Get

func Get(area_id string) *AreaType

创建一个场景

type Session

type Session struct {
	IP          string
	User        string
	LoggedIn    bool
	KickOut     bool
	Sid         string
	ConnectTime int64
	PacketTime  int64
}

用户结构

Jump to

Keyboard shortcuts

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