SetMainDcId() public method

public SetMainDcId ( int id ) : void
id int
return void
Exemplo n.º 1
0
        private static TelegramSession loadIfExists()
        {
            TelegramSession session;

            lock (typeof(TelegramSession)) {
                try {
                    using (IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication())
                        using (Stream fileStream = new IsolatedStorageFileStream("session.dat", FileMode.Open, fileStorage))
                            using (BinaryReader fileReader = new BinaryReader(fileStream)) {
                                session = new TelegramSession(fileReader);
                                logger.info("loaded telegram session: {0}", session);
                            }
                } catch (Exception e) {
                    logger.info("error loading session, create new...: {0}", e);

                    logger.info("cleaning contacts");
                    CleanContacts();

                    ulong sessionId = Helpers.GenerateRandomUlong();
                    session = new TelegramSession(sessionId, 0);
                    // prod 173.240.5.1
                    // test 173.240.5.253
                    TelegramEndpoint endpoint = new TelegramEndpoint("173.240.5.1", 443);
                    TelegramDC       dc       = new TelegramDC();
                    dc.Endpoints.Add(endpoint);
                    session.Dcs.Add(1, dc);
                    session.SetMainDcId(1);


                    logger.info("created new telegram session: {0}", session);
                }
            }

            return(session);
        }
Exemplo n.º 2
0
        private static TelegramSession loadIfExists() {
            TelegramSession session;
            lock(typeof(TelegramSession)) {
                try {
                    using(IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication())
                    using(Stream fileStream = new IsolatedStorageFileStream("session.dat", FileMode.Open, fileStorage))
                    using(BinaryReader fileReader = new BinaryReader(fileStream)) {
                        session = new TelegramSession(fileReader);
                        logger.info("loaded telegram session: {0}", session);
                    }
                } catch(Exception e) {
                    logger.info("error loading session, create new...: {0}", e);

                    logger.info("cleaning contacts");
                    CleanContacts();

                    ulong sessionId = Helpers.GenerateRandomUlong();
                    session = new TelegramSession(sessionId, 0);
                    // prod 173.240.5.1 
                    // test 173.240.5.253
                    TelegramEndpoint endpoint = new TelegramEndpoint("173.240.5.1", 443);
                    TelegramDC dc = new TelegramDC();
                    dc.Endpoints.Add(endpoint);
                    session.Dcs.Add(1, dc);
                    session.SetMainDcId(1);


                    logger.info("created new telegram session: {0}", session);
                }
            }

            return session;
        }