/// <summary> /// Creates a new TelegramClient /// </summary> /// <param name="apiId">The API ID provided by Telegram. Get one at https://my.telegram.org </param> /// <param name="apiHash">The API Hash provided by Telegram. Get one at https://my.telegram.org </param> /// <param name="store">An ISessionStore object that will handle the session</param> /// <param name="sessionUserId">The name of the session that tracks login info about this TelegramClient connection</param> /// <param name="handler">A delegate to invoke when a connection is needed and that will return a TcpClient that will be used to connect</param> /// <param name="dcIpVersion">Indicates the preferred IpAddress version to use to connect to a Telegram server</param> public TelegramClient(int apiId, string apiHash, DataCenterIPVersion dcIpVersion = DataCenterIPVersion.Default, ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null ) { if (apiId == default(int)) { throw new MissingApiConfigurationException("API_ID"); } if (string.IsNullOrEmpty(apiHash)) { throw new MissingApiConfigurationException("API_HASH"); } if (store == null) { store = new FileSessionStore(); } this.store = store; this.apiHash = apiHash; this.apiId = apiId; this.handler = handler; this.dcIpVersion = dcIpVersion; this.sessionUserId = sessionUserId; }
/// <summary> /// Creates a new TelegramClient /// </summary> /// <param name="apiId">The API ID provided by Telegram. Get one at https://my.telegram.org </param> /// <param name="apiHash">The API Hash provided by Telegram. Get one at https://my.telegram.org </param> /// <param name="store">An ISessionStore object that will handle the session</param> /// <param name="sessionUserId">The name of the session that tracks login info about this TelegramClient connection</param> /// <param name="handler">A delegate to invoke when a connection is needed and that will return a TcpClient that will be used to connect</param> /// <param name="dcIpVersion">Indicates the preferred IpAddress version to use to connect to a Telegram server</param> public TelegramClient(int apiId, string apiHash, ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null, DataCenterIPVersion dcIpVersion = DataCenterIPVersion.Default) { if (apiId == default(int)) { throw new MissingApiConfigurationException("API_ID"); } if (string.IsNullOrEmpty(apiHash)) { throw new MissingApiConfigurationException("API_HASH"); } if (store == null) { store = new FileSessionStore(); } this.apiHash = apiHash; this.apiId = apiId; this.handler = handler; this.dcIpVersion = dcIpVersion; session = Session.TryLoadOrCreateNew(store, sessionUserId); transport = new TcpTransport(session.DataCenter.Address, session.DataCenter.Port, this.handler); }