// // SocketMsgModel.m // OneCable // // Created by KaRam Kim on 2017. 4. 20.. // Copyright © 2017년 ntels. All rights reserved. // #import "SocketMsgModel.h" #define MSG_TYPE_KEY @"message_type" #define REQUEST_ID_KEY @"request_id" @implementation SocketRequestModel -(id)initWithMsgType:(NSString *)msgType { if (self = [super init]) { self.messageType = msgType; } return self; } //-(void)setRequestId:(int)requestId //{ // NSLog(@"Request ID : %d", requestId); // self.requestId = [NSString stringWithFormat:@"%d", requestId]; //} -(NSString *)getSendMessage { NSMutableDictionary *info = [[NSMutableDictionary alloc] initWithDictionary:_requestMsg]; info[MSG_TYPE_KEY] = self.messageType; info[REQUEST_ID_KEY] = self.requestId; NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:info options:NSJSONWritingPrettyPrinted error:&error]; NSString *result = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; if (!error) { NSLog(@"Got an error: %@", error); } return result; } @end