-
Notifications
You must be signed in to change notification settings - Fork 0
/
member.go
55 lines (45 loc) · 946 Bytes
/
member.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package hoom
import "fmt"
import (
"github.com/kmcsr/go-pio/encoding"
hdata "github.com/kmcsr/go-hoom/data"
)
type Member = hdata.Member
var NewMember = hdata.NewMember
func WriteMember(w encoding.Writer, m *Member)(err error){
if err = w.WriteUint32(m.Id()); err != nil {
return
}
return
}
func ParseMember(r encoding.Reader)(m *Member, err error){
var memid uint32
if memid, err = r.ReadUint32(); err != nil {
return
}
return QueryMember(memid)
}
func QueryMember(id uint32)(m *Member, err error){
m = NewMember(id, fmt.Sprintf("user-%d", id))
return
}
type AuthedMember struct{
*Member
authToken string
}
func LogMember(id uint32, token string)(m *AuthedMember, err error){
var m0 *Member
if m0, err = QueryMember(id); err != nil {
return
}
// TODO: auth member
authToken := ""
m = &AuthedMember{
Member: m0,
authToken: authToken,
}
return
}
func (m *AuthedMember)GetMem()(*Member){
return m.Member
}