package core import ( "fmt" "github.com/aceld/zinx/ziface" "github.com/google/uuid" ) // User User 对象 type User struct { UID string //ID Conn ziface.IConnection //当前User的连接 LoginState bool LoginCount int AlarmType string UserName string SeqNo string // 登录随机码 RemoteIp string } // NewUser 创建一个user对象 func NewUser(conn ziface.IConnection, addr string) *User { p := &User{ UID: uuid.NewString(), Conn: conn, RemoteIp: addr, } return p } // LostConnection User下线 func (p *User) LostConnection(m *ChannelManager) { m.RemoveUserByPID(p.UID) } // SendMsg /* func (p *User) SendMsg(msgID uint32, msg []byte) { if p.Conn == nil { fmt.Println("connection in player is nil") return } //调用SendMsg发包 if err := p.Conn.SendMsg(msgID, msg); err != nil { fmt.Println("Player SendMsg error !") return } return }