public void Save(Session session) { using (var stream = new FileStream($"{session.SessionUserId}.dat", FileMode.OpenOrCreate)) { var result = session.ToBytes(); stream.Write(result, 0, result.Length); } }
public void Save(Session session) { string sessionFileName = $"{session.SessionUserId}.dat"; var sessionPath = basePath == null ? sessionFileName : Path.Combine(basePath.FullName, sessionFileName); using (var stream = new FileStream(sessionPath, FileMode.OpenOrCreate)) { var result = session.ToBytes(); stream.Write(result, 0, result.Length); } }
public void Save(Session session) { //string path = "App_Data\\Telegram"; string path = "wwwroot\\App_Data\\Telegram"; // debug only string sessionFileName = $"{path}\\{session.SessionUserId}.dat"; var sessionPath = basePath == null ? sessionFileName : Path.Combine(basePath.FullName, sessionFileName); using (var stream = new FileStream(sessionPath, FileMode.OpenOrCreate)) { var result = session.ToBytes(); stream.Write(result, 0, result.Length); } }
public void Save(Session session) { string Path = string.Empty; if (session.SessionPath != null) { Path += session.SessionPath; } Path += session.SessionUserId; using (var stream = new FileStream($"{Path}.dat", FileMode.OpenOrCreate)) { var result = session.ToBytes(); stream.Write(result, 0, result.Length); } }
private async Task MakeRequestAtDataCenterWithTemporarySubClient(TLMethod request, int dataCenter) { var fakeStore = new FakeSessionStore(); var subClient = new TelegramClient(_apiId, _apiHash, fakeStore, "session", null, _useIpV6DataCenters) { _session = Session.FromBytes(_session.ToBytes(), fakeStore, "session"), _transport = new TcpTransport(_session.DataCenter.Address, _session.DataCenter.Port, _handler) }; await subClient.ConnectAsync(); await subClient.ReconnectToDcAsync(dataCenter); request.ConfirmReceived = false; await subClient.RequestWithDcMigration(request); _session.LastMessageId = subClient._session.LastMessageId; _session.Sequence = subClient._session.Sequence; }