You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2014 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #import "ARDMessageResponse+Internal.h"
  11. #import "ARDUtilities.h"
  12. static NSString const *kARDMessageResultKey = @"result";
  13. @implementation ARDMessageResponse
  14. @synthesize result = _result;
  15. + (ARDMessageResponse *)responseFromJSONData:(NSData *)data {
  16. NSDictionary *responseJSON = [NSDictionary dictionaryWithJSONData:data];
  17. if (!responseJSON) {
  18. return nil;
  19. }
  20. ARDMessageResponse *response = [[ARDMessageResponse alloc] init];
  21. response.result =
  22. [[self class] resultTypeFromString:responseJSON[kARDMessageResultKey]];
  23. return response;
  24. }
  25. #pragma mark - Private
  26. + (ARDMessageResultType)resultTypeFromString:(NSString *)resultString {
  27. ARDMessageResultType result = kARDMessageResultTypeUnknown;
  28. if ([resultString isEqualToString:@"SUCCESS"]) {
  29. result = kARDMessageResultTypeSuccess;
  30. } else if ([resultString isEqualToString:@"INVALID_CLIENT"]) {
  31. result = kARDMessageResultTypeInvalidClient;
  32. } else if ([resultString isEqualToString:@"INVALID_ROOM"]) {
  33. result = kARDMessageResultTypeInvalidRoom;
  34. }
  35. return result;
  36. }
  37. @end