MCPcopy Index your code
hub / github.com/dearcode/candy / getSession

Method getSession

gate/server.go:85–109  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

83}
84
85func (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
111func (g *Gate) online(s *session, id int64) {
112 s.online(id)

Callers 9

getOnlineSessionMethod · 0.95
RegisterMethod · 0.95
UpdateUserInfoMethod · 0.95
UpdateUserPasswordMethod · 0.95
LoginMethod · 0.95
LogoutMethod · 0.95
SendMessageMethod · 0.95
ReadyMethod · 0.95
HeartbeatMethod · 0.95

Calls 1

newSessionFunction · 0.85

Tested by

no test coverage detected