chat

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Room

type Room struct {
	UserListByUserID sync.Map //存储*User字典,以用户ID为key
	CurNum           int32
	MaxNum           int32
	Title            string
	RoomID           int32
}

func (*Room) AddUser

func (self *Room) AddUser(userID int64) error

添加房间成员

func (*Room) GetAllUser

func (self *Room) GetAllUser() []*User

获取房间成员

func (*Room) RemoveUser

func (self *Room) RemoveUser(userID int64) bool

移除房间消息

type RoomManager

type RoomManager struct {
	RoomNum      int32
	RoomListByID sync.Map
	RoomIDSeq    int32
}
var RoomManagerInstance *RoomManager

func GetRoomManager

func GetRoomManager() *RoomManager

func (*RoomManager) CreateRoom

func (self *RoomManager) CreateRoom(title string, userID int64) *Room

func (*RoomManager) GetRoomInfo

func (self *RoomManager) GetRoomInfo(roomID int32) (room *Room, ok bool)

根据房间号获取房间信息

func (*RoomManager) JoinRoom

func (self *RoomManager) JoinRoom(roomID int32, userID int64) (room *Room, err error)

type User

type User struct {
	UserID int64
	Name   string
	Avatar string
	RoomID int32
	CID    proto.ClientID
}

type UserManager

type UserManager struct {
	UserNum      int32
	UserListByID sync.Map
}
var UserManagerInstance *UserManager

func GetUserManager

func GetUserManager() *UserManager

func (*UserManager) AddUser

func (self *UserManager) AddUser(cid proto.ClientID, name string, avatar string) bool

添加用户

func (*UserManager) BindUserRoom

func (self *UserManager) BindUserRoom(userID int64, roomID int32)

绑定用户房间

func (*UserManager) GetUser

func (self *UserManager) GetUser(userID int64) (*User, error)

func (*UserManager) RemoveUser

func (self *UserManager) RemoveUser(userID int64)

删除用户

Jump to

Keyboard shortcuts

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