mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-21 13:54:15 -07:00
Replace NodeStatus object with Obj-C Class
This commit is contained in:
parent
a08246ce5d
commit
7a12d8193b
5 changed files with 63 additions and 63 deletions
25
ZeroTier One/NodeStatus.h
Normal file
25
ZeroTier One/NodeStatus.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// NodeStatus.h
|
||||
// ZeroTier One
|
||||
//
|
||||
// Created by Grant Limberg on 8/4/16.
|
||||
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NodeStatus : NSObject
|
||||
|
||||
@property (readonly) NSString *address;
|
||||
@property (readonly) NSString *publicIdentity;
|
||||
@property (readonly) BOOL online;
|
||||
@property (readonly) BOOL tcpFallbackActive;
|
||||
@property (readonly) int versionMajor;
|
||||
@property (readonly) int versionMinor;
|
||||
@property (readonly) int versionRev;
|
||||
@property (readonly) NSString *version;
|
||||
@property (readonly) UInt64 clock;
|
||||
|
||||
- (id)initWithJsonData:(NSDictionary*)jsonData;
|
||||
|
||||
@end
|
31
ZeroTier One/NodeStatus.m
Normal file
31
ZeroTier One/NodeStatus.m
Normal file
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// NodeStatus.m
|
||||
// ZeroTier One
|
||||
//
|
||||
// Created by Grant Limberg on 8/4/16.
|
||||
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NodeStatus.h"
|
||||
|
||||
@implementation NodeStatus
|
||||
|
||||
- (id)initWithJsonData:(NSDictionary*)jsonData
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if(self) {
|
||||
_address = (NSString*)[jsonData objectForKey:@"address"];
|
||||
_publicIdentity = (NSString*)[jsonData objectForKey:@"publicIdentity"];
|
||||
_online = [(NSNumber*)[jsonData objectForKey:@"online"] boolValue];
|
||||
_tcpFallbackActive = [(NSNumber*)[jsonData objectForKey:@"tcpFallbackActive"] boolValue];
|
||||
_versionMajor = [(NSNumber*)[jsonData objectForKey:@"versionMajor"] intValue];
|
||||
_versionMinor = [(NSNumber*)[jsonData objectForKey:@"versionMinor"] intValue];
|
||||
_versionRev = [(NSNumber*)[jsonData objectForKey:@"versionRev"] intValue];
|
||||
_version = (NSString*)[jsonData objectForKey:@"version"];
|
||||
_clock = [(NSNumber*)[jsonData objectForKey:@"clock"] unsignedLongLongValue];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
@end
|
|
@ -1,59 +0,0 @@
|
|||
//
|
||||
// NodeStatus.swift
|
||||
// ZeroTier One
|
||||
//
|
||||
// Created by Grant Limberg on 6/30/16.
|
||||
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class NodeStatus: NSObject {
|
||||
var address: String = ""
|
||||
var publicIdentity: String = ""
|
||||
var online: Bool = false
|
||||
var tcpFallbackActive: Bool = false
|
||||
var versionMajor: Int = 0
|
||||
var versionMinor: Int = 0
|
||||
var versionRev: Int = 0
|
||||
var version: String = ""
|
||||
var clock: UInt64 = 0
|
||||
|
||||
init(jsonData: [String: AnyObject]) {
|
||||
if let a = jsonData["address"] as? String {
|
||||
self.address = a
|
||||
}
|
||||
|
||||
if let p = jsonData["publicIdentity"] as? String {
|
||||
self.publicIdentity = p
|
||||
}
|
||||
|
||||
if let o = jsonData["online"] as? NSNumber {
|
||||
self.online = o.boolValue
|
||||
}
|
||||
|
||||
if let t = jsonData["tcpFallbackActive"] as? NSNumber {
|
||||
self.tcpFallbackActive = t.boolValue
|
||||
}
|
||||
|
||||
if let v = jsonData["versionMajor"] as? NSNumber {
|
||||
self.versionMajor = v.integerValue
|
||||
}
|
||||
|
||||
if let v = jsonData["versionMinor"] as? NSNumber {
|
||||
self.versionMinor = v.integerValue
|
||||
}
|
||||
|
||||
if let v = jsonData["versionRev"] as? NSNumber {
|
||||
self.versionRev = v.integerValue
|
||||
}
|
||||
|
||||
if let v = jsonData["version"] as? String {
|
||||
self.version = v
|
||||
}
|
||||
|
||||
if let c = jsonData["version"] as? NSNumber {
|
||||
self.clock = c.unsignedLongLongValue
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,3 +4,4 @@
|
|||
|
||||
#import "AuthtokenCopy.h"
|
||||
#import "LaunchAtLoginController.h"
|
||||
#import "NodeStatus.h"
|
Loading…
Add table
Add a link
Reference in a new issue