static void Main(string[] args) { TLContext.Init(); ObjectUtils.ServerSide = true; Console.WriteLine("Listening..."); TcpListener(); Console.WriteLine("The end"); Console.ReadKey(); }
public TelegramClient(int apiId, string apiHash, 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(); } TLContext.Init(); _apiHash = apiHash; _apiId = apiId; _handler = handler; _session = Session.TryLoadOrCreateNew(store, sessionUserId); _transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler); }
public TelegramClient(int apiId, string apiHash, ISessionStore store = null, string sessionUserId = "session", string AppVersion = "1.0", string DeviceModel = "PC", string LangCode = "en", string SystemVersion = "Windows", TcpClientConnectionHandler handler = null) { try { if (apiId == default(int)) { throw new MissingApiConfigurationException("API_ID"); } if (string.IsNullOrEmpty(apiHash)) { throw new MissingApiConfigurationException("API_HASH"); } if (store == null) { store = new FileSessionStore(); } TLContext.Init(); _apiHash = apiHash; _apiId = apiId; _appVersion = AppVersion; _DeviceModel = DeviceModel; _LangCode = LangCode; _SystemVersion = SystemVersion; _handler = handler; _session = Session.TryLoadOrCreateNew(store, sessionUserId); _transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler); } catch { throw new Exception("Not connected to the internet"); } }
public TelegramClient(int apiId, string apiHash, ISessionStore store = null, string sessionUserId = "session") { if (store == null) { store = new FileSessionStore(); } TLContext.Init(); _apiHash = apiHash; _apiId = apiId; if (_apiId == 0) { throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration"); } if (string.IsNullOrEmpty(_apiHash)) { throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration"); } _session = Session.TryLoadOrCreateNew(store, sessionUserId); _transport = new TcpTransport(_session.ServerAddress, _session.Port); }