public static async Task <TelegramClient> Connect( int apiId, ISessionStore?store = null, IPEndPoint?endpoint = null, TgCallMiddlewareChain?callMiddlewareChain = null, TcpClientConnectionHandler?tcpClientConnectionHandler = null ) { store ??= new FileSessionStore("session.dat"); var ep = endpoint ?? DefaultEndpoint; var connectInfo = (await store.Load().ConfigureAwait(false)) .Map(SomeExt.ToSome).Map(ConnectInfo.FromSession) .IfNone(ConnectInfo.FromInfo(apiId, ep)); return(await Connect(connectInfo, store, callMiddlewareChain, tcpClientConnectionHandler)); }