增加对会话操作的优化提示
This commit is contained in:
@ -8,16 +8,21 @@ import (
|
||||
)
|
||||
|
||||
type Tun struct {
|
||||
Tun *guacd.Tunnel
|
||||
Tunnel *guacd.Tunnel
|
||||
SftpClient *sftp.Client
|
||||
WebSocket *websocket.Conn
|
||||
}
|
||||
|
||||
type Observable struct {
|
||||
Subject *Tun
|
||||
Observers []Tun
|
||||
}
|
||||
|
||||
type TunStore struct {
|
||||
m sync.Map
|
||||
}
|
||||
|
||||
func (s *TunStore) Set(k string, v *Tun) {
|
||||
func (s *TunStore) Set(k string, v *Observable) {
|
||||
s.m.Store(k, v)
|
||||
}
|
||||
|
||||
@ -25,10 +30,10 @@ func (s *TunStore) Del(k string) {
|
||||
s.m.Delete(k)
|
||||
}
|
||||
|
||||
func (s *TunStore) Get(k string) (item *Tun, ok bool) {
|
||||
func (s *TunStore) Get(k string) (item *Observable, ok bool) {
|
||||
value, ok := s.m.Load(k)
|
||||
if ok {
|
||||
return value.(*Tun), true
|
||||
return value.(*Observable), true
|
||||
}
|
||||
return item, false
|
||||
}
|
||||
|
Reference in New Issue
Block a user