-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsession.go
More file actions
39 lines (34 loc) · 881 Bytes
/
session.go
File metadata and controls
39 lines (34 loc) · 881 Bytes
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
package gweb
import "sync"
var Sessions = &sessionMap{Data: make(map[string]*Session)}
type sessionMap struct {
sync.RWMutex
Data map[string]*Session
}
type Session struct {
sync.RWMutex
Attributes *Attributes
CreateTime int64
ActionTime int64
Operation int64
GLSESSIONID string
}
func (s *sessionMap) DelectSession(k string) {
s.Lock()
delete(s.Data, k)
defer s.Unlock()
//db.NotifyAll(&db.Message{db.Socket_Type_2_STC,k})
}
func (s *sessionMap) addSession(GLSESSIONID string, session *Session) {
s.Lock()
s.Data[GLSESSIONID] = session
defer s.Unlock()
//db.NotifyAll(&db.Message{db.Socket_Type_1_STC,session})
}
func (s *sessionMap) GetSession(GLSESSIONID string) *Session {
s.RLock()
session := s.Data[GLSESSIONID]
defer s.RUnlock()
//db.NotifyAll(&db.Message{db.Socket_Type_1_STC,session})
return session
}