mirror of https://github.com/oxen-io/session-ios
Integrating socket status indicator and remove favorites.
parent
8b6ac13594
commit
ad5bb92004
@ -1,29 +0,0 @@
|
|||||||
//
|
|
||||||
// Socket.h
|
|
||||||
// Signal
|
|
||||||
//
|
|
||||||
// Created by Dylan Bourgeois on 18/11/14.
|
|
||||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
typedef enum : NSUInteger {
|
|
||||||
kSocketStatusOpen,
|
|
||||||
kSocketStatusClosed,
|
|
||||||
kSocketStatusConnecting,
|
|
||||||
} SocketStatus;
|
|
||||||
|
|
||||||
static void *kSocketStatusObservationContext = &kSocketStatusObservationContext;
|
|
||||||
|
|
||||||
extern NSString * const SocketOpenedNotification;
|
|
||||||
extern NSString * const SocketClosedNotification;
|
|
||||||
extern NSString * const SocketConnectingNotification;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
@interface Socket : NSObject
|
|
||||||
|
|
||||||
@property (nonatomic) SocketStatus status;
|
|
||||||
|
|
||||||
@end
|
|
@ -1,52 +0,0 @@
|
|||||||
//
|
|
||||||
// Socket.m
|
|
||||||
// Signal
|
|
||||||
//
|
|
||||||
// Created by Dylan Bourgeois on 18/11/14.
|
|
||||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
#import "Socket.h"
|
|
||||||
|
|
||||||
NSString * const SocketOpenedNotification = @"SocketOpenedNotification";
|
|
||||||
NSString * const SocketClosedNotification = @"SocketClosedNotification";
|
|
||||||
NSString * const SocketConnectingNotification = @"SocketConnectingNotification";
|
|
||||||
|
|
||||||
@implementation Socket
|
|
||||||
|
|
||||||
-(instancetype)init
|
|
||||||
{
|
|
||||||
if (self = [super init])
|
|
||||||
{
|
|
||||||
_status = kSocketStatusConnecting;
|
|
||||||
[self addObserver:self forKeyPath:@"status" options:0 context:kSocketStatusObservationContext];
|
|
||||||
}
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
|
||||||
|
|
||||||
if (context == kSocketStatusObservationContext)
|
|
||||||
{
|
|
||||||
switch (self.status) {
|
|
||||||
case kSocketStatusOpen:
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:SocketOpenedNotification object:self];
|
|
||||||
break;
|
|
||||||
case kSocketStatusClosed:
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:SocketClosedNotification object:self];
|
|
||||||
break;
|
|
||||||
case kSocketStatusConnecting:
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:SocketConnectingNotification object:self];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
|
Loading…
Reference in New Issue