Flutter Engine
FlutterObservatoryPublisher Class Reference

#import <FlutterObservatoryPublisher.h>

Inheritance diagram for FlutterObservatoryPublisher:

Instance Methods

(instancetype) - initWithEnableObservatoryPublication:
 
(instancetype) - NS_UNAVAILABLE
 

Class Methods

(instancetype) + NS_UNAVAILABLE
 

Properties

NSURL * url
 

Detailed Description

Definition at line 10 of file FlutterObservatoryPublisher.h.

Method Documentation

◆ initWithEnableObservatoryPublication:()

- (instancetype) initWithEnableObservatoryPublication: (BOOL)  NS_DESIGNATED_INITIALIZER

Definition at line 187 of file FlutterObservatoryPublisher.mm.

References _weakFactory, flutter::DartServiceIsolate::AddServerStatusCallback(), fml::MessageLoop::EnsureInitializedForCurrentThread(), fml::MessageLoop::GetCurrent(), fml::MessageLoop::GetTaskRunner(), flutter::path, flutter::DartServiceIsolate::RemoveServerStatusCallback(), and url.

187  :(BOOL)enableObservatoryPublication {
188  self = [super init];
189  NSAssert(self, @"Super must not return null on init.");
190 
191  if (@available(iOS 9.3, *)) {
192  _delegate.reset([[ObservatoryDNSServiceDelegate alloc] init]);
193  } else {
194  _delegate.reset([[ObservatoryNSNetServiceDelegate alloc] init]);
195  }
196  _enableObservatoryPublication = enableObservatoryPublication;
197  _weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterObservatoryPublisher>>(self);
198 
200 
202  [weak = _weakFactory->GetWeakPtr(),
203  runner = fml::MessageLoop::GetCurrent().GetTaskRunner()](const std::string& uri) {
204  if (!uri.empty()) {
205  runner->PostTask([weak, uri]() {
206  // uri comes in as something like 'http://127.0.0.1:XXXXX/' where XXXXX is the port
207  // number.
208  if (weak) {
209  NSURL* url =
210  [[NSURL alloc] initWithString:[NSString stringWithUTF8String:uri.c_str()]];
211  weak.get().url = url;
212  if (weak.get().enableObservatoryPublication) {
213  [[weak.get() delegate] publishServiceProtocolPort:url];
214  }
215  }
216  });
217  }
218  });
219 
220  return self;
221 }
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19
static void EnsureInitializedForCurrentThread()
Definition: message_loop.cc:27
static CallbackHandle AddServerStatusCallback(const ObservatoryServerStateCallback &callback)
Add a callback that will get invoked when the observatory starts up. If the observatory has already s...
std::unique_ptr< fml::WeakPtrFactory< FlutterObservatoryPublisher > > _weakFactory
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: message_loop.cc:56

◆ NS_UNAVAILABLE() [1/2]

+ (instancetype) NS_UNAVAILABLE

◆ NS_UNAVAILABLE() [2/2]

- (instancetype) NS_UNAVAILABLE

Property Documentation

◆ url

- (NSURL*) url
readnonatomicassign

Definition at line 17 of file FlutterObservatoryPublisher.h.

Referenced by initWithEnableObservatoryPublication:.


The documentation for this class was generated from the following files: