Source File
session.go
Belonging Package
github.com/gotd/td/internal/pool
package poolimport ()// Session represents DC session.type Session struct {DC intAuthKey crypto.AuthKeySalt int64}// SyncSession is synchronization helper for Session.type SyncSession struct {data Sessionmux sync.RWMutex}// NewSyncSession creates new SyncSession.func ( Session) *SyncSession {return &SyncSession{data: ,}}// Store saves given Session.func ( *SyncSession) ( Session) {.mux.Lock().data =.mux.Unlock()}// Migrate changes current DC and its addr, zeroes AuthKey and Salt.func ( *SyncSession) ( int) {.mux.Lock().data.DC =.data.AuthKey = crypto.AuthKey{}.data.Salt = 0.mux.Unlock()}// Options fills Key and Salt field of given Options using stored session and returns it.func ( *SyncSession) ( mtproto.Options) (mtproto.Options, Session) {.mux.RLock():= .data.mux.RUnlock().Key = .AuthKey.Salt = .Saltreturn ,}// Load gets session and returns it.func ( *SyncSession) () ( Session) {.mux.RLock()= .data.mux.RUnlock()return}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |