增加对会话操作的优化提示

This commit is contained in:
dushixiang
2021-01-25 23:23:19 +08:00
parent 31f3bad243
commit ac99332453
9 changed files with 175 additions and 116 deletions

View File

@ -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
}