TLSharp.Core.Session.TryLoadOrCreateNew C# (CSharp) Method

TryLoadOrCreateNew() public static method

public static TryLoadOrCreateNew ( ISessionStore store, string sessionUserId ) : Session
store ISessionStore
sessionUserId string
return Session
        public static Session TryLoadOrCreateNew(ISessionStore store, string sessionUserId)
        {
            return store.Load(sessionUserId) ?? new Session(store)
            {
                Id = GenerateRandomUlong(),
                SessionUserId = sessionUserId,
                ServerAddress = defaultConnectionAddress,
                Port = defaultConnectionPort
            };
        }

Usage Example

Example #1
0
 public TelegramClient(ISessionStore store, string sessionUserId, int apiId, string apiHash)
 {
     _apiId     = apiId;
     _apiHash   = apiHash;
     _session   = Session.TryLoadOrCreateNew(store, sessionUserId);
     _transport = new TcpTransport(_session.ServerAddress, _session.Port);
 }
All Usage Examples Of TLSharp.Core.Session::TryLoadOrCreateNew