SocketMsgModel.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // SocketMsgModel.m
  3. // OneCable
  4. //
  5. // Created by KaRam Kim on 2017. 4. 20..
  6. // Copyright © 2017년 ntels. All rights reserved.
  7. //
  8. #import "SocketMsgModel.h"
  9. #define MSG_TYPE_KEY @"message_type"
  10. #define REQUEST_ID_KEY @"request_id"
  11. @implementation SocketRequestModel
  12. -(id)initWithMsgType:(NSString *)msgType
  13. {
  14. if (self = [super init]) {
  15. self.messageType = msgType;
  16. }
  17. return self;
  18. }
  19. //-(void)setRequestId:(int)requestId
  20. //{
  21. // NSLog(@"Request ID : %d", requestId);
  22. // self.requestId = [NSString stringWithFormat:@"%d", requestId];
  23. //}
  24. -(NSString *)getSendMessage
  25. {
  26. NSMutableDictionary *info = [[NSMutableDictionary alloc] initWithDictionary:_requestMsg];
  27. info[MSG_TYPE_KEY] = self.messageType;
  28. info[REQUEST_ID_KEY] = self.requestId;
  29. NSError *error;
  30. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:info
  31. options:NSJSONWritingPrettyPrinted
  32. error:&error];
  33. NSString *result = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  34. if (!error)
  35. {
  36. NSLog(@"Got an error: %@", error);
  37. }
  38. return result;
  39. }
  40. @end
  41. @implementation SocketReponseModel
  42. @end
  43. @implementation CommandModel
  44. @end
  45. @implementation SoKDeviceModel
  46. @end
  47. @implementation SoKNodeModel
  48. @end
  49. @implementation ContentModel
  50. @end