rpc 패키지 적용
This commit is contained in:
@ -27,19 +27,6 @@ func (rc *connection) addTag(name, val string) {
|
||||
rc.tags = append(rc.tags, prefix+val)
|
||||
}
|
||||
|
||||
func (rc *connection) getTag(name string) string {
|
||||
rc.locker.Lock()
|
||||
defer rc.locker.Unlock()
|
||||
|
||||
prefix := name + "="
|
||||
for _, tag := range rc.tags {
|
||||
if strings.HasPrefix(tag, prefix) {
|
||||
return tag[len(prefix):]
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (rc *connection) removeTag(name string, val string) {
|
||||
rc.locker.Lock()
|
||||
defer rc.locker.Unlock()
|
||||
@ -95,3 +82,16 @@ func (rc *connection) unregistOnCloseFunc(name string) (out func()) {
|
||||
delete(rc.onClose, name)
|
||||
return
|
||||
}
|
||||
|
||||
func (rc *connection) cleanup() {
|
||||
rc.locker.Lock()
|
||||
defer rc.locker.Unlock()
|
||||
|
||||
cp := rc.onClose
|
||||
rc.onClose = nil
|
||||
go func() {
|
||||
for _, f := range cp {
|
||||
f()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user