(ctx context.Context)
| 83 | } |
| 84 | |
| 85 | func (g *Gate) getSession(ctx context.Context) (*session, error) { |
| 86 | log.Debug("Gate getSession") |
| 87 | md, ok := metadata.FromContext(ctx) |
| 88 | if !ok { |
| 89 | return nil, errors.Trace(ErrInvalidContext) |
| 90 | } |
| 91 | |
| 92 | addrs, ok := md["remote"] |
| 93 | if !ok { |
| 94 | return nil, errors.Trace(ErrInvalidContext) |
| 95 | } |
| 96 | |
| 97 | g.RLock() |
| 98 | s, ok := g.sessions[addrs[0]] |
| 99 | g.RUnlock() |
| 100 | |
| 101 | if !ok { |
| 102 | s = newSession(addrs[0]) |
| 103 | g.Lock() |
| 104 | g.sessions[addrs[0]] = s |
| 105 | g.Unlock() |
| 106 | } |
| 107 | |
| 108 | return s, nil |
| 109 | } |
| 110 | |
| 111 | func (g *Gate) online(s *session, id int64) { |
| 112 | s.online(id) |
no test coverage detected