1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-02 09:27:55 +01:00
Telegram/Telegraph/TGExclusiveLiveNearbyActor.m
2014-07-10 18:11:09 +04:00

63 lines
1.5 KiB
Objective-C

#import "TGExclusiveLiveNearbyActor.h"
#import "ActionStage.h"
#import "TGLiveNearbyActor.h"
@implementation TGExclusiveLiveNearbyActor
@synthesize actionHandle = _actionHandle;
+ (NSString *)genericPath
{
return @"/tg/exclusiveLiveNearby/@";
}
- (id)initWithPath:(NSString *)path
{
self = [super initWithPath:path];
if (self != nil)
{
_actionHandle = [[ASHandle alloc] initWithDelegate:self releaseOnMainThread:false];
_actionHandle.delegate = self;
if ([path hasSuffix:@"(holdTimeout)"])
self.cancelTimeout = 5 * 60;
}
return self;
}
- (void)dealloc
{
[_actionHandle reset];
[ActionStageInstance() removeWatcher:self];
}
- (void)execute:(NSDictionary *)__unused options
{
[ActionStageInstance() requestActor:@"/tg/liveNearby" options:nil watcher:self];
if ([self.path hasSuffix:@"(discloseLocation)"])
{
TGLiveNearbyActor *actor = (TGLiveNearbyActor *)[ActionStageInstance() executingActorWithPath:@"/tg/liveNearby"];
if (actor != nil)
{
actor.discloseLocation = true;
[actor forceCheckNearby];
}
}
}
- (void)cancel
{
[ActionStageInstance() removeWatcher:self];
if ([self.path hasSuffix:@"(discloseLocation)"])
{
TGLiveNearbyActor *actor = (TGLiveNearbyActor *)[ActionStageInstance() executingActorWithPath:@"/tg/liveNearby"];
if (actor != nil)
actor.discloseLocation = false;
}
}
@end