title: IOS SocketIO chat app issues, Node JS as backend
body: <p>Friends</p>
  
  <p>i am working on a chat application where there a function in backend like </p>
  
  <pre><code> client.on('mjmChatAddUser', function(user, room)
      {
          // Guest
          if(user == null)
              user = mjmChatCreateGuestName();
  
          // Convert special characters to HTML entities
          user = htmlEntities(user);
          room = htmlEntities(room);
  
          client.username = user;
          client.room = room;
          mjmChatUsernames.push(user);
          client.join(room);
  
          client.emit('mjmChatStatusUser', 'you have joined to '+ room +' room');
  
          client.broadcast.to(room).emit('mjmChatStatusUser', user +' has joined to this room');
          client.emit('mjmChatRooms', room);
  
          io.sockets.to(room).emit('mjmChatUsers', mjmChatGetUsersRoom(room));
      });
  </code></pre>
  
  <p>Now from ios side , I want to use ScoketIO to call this function , I have  made connection to server but not enable to call this function , this what i am doing , is it right way , please guide me</p>
  
  <pre><code>- (void) viewDidLoad
  {
      [super viewDidLoad];
  
      // create socket.io client instance
      socketIO = [[SocketIO alloc] initWithDelegate:self];
  
      // you can update the resource name of the handshake URL
      // see https://github.com/pkyeck/socket.IO-objc/pull/80
      // [socketIO setResourceName:@"whatever"];
  
      // if you want to use https instead of http
      // socketIO.useSecure = YES;
  
      // pass cookie(s) to handshake endpoint (e.g. for auth)
      NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
                                      @"localhost", NSHTTPCookieDomain,
                                      @"/", NSHTTPCookiePath,
                                      @"auth", NSHTTPCookieName,
                                      @"56cdea636acdf132", NSHTTPCookieValue,
                                      nil];
      NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:properties];
      NSArray *cookies = [NSArray arrayWithObjects:cookie, nil];
  
      socketIO.cookies = cookies;
  
      // connect to the socket.io server that is running locally at port 3000
      [socketIO connectToHost:@"MY SERVER" onPort:3000];
  
  }
  
  # pragma mark -
  # pragma mark socket.IO-objc delegate methods
  
  - (void) socketIODidConnect:(SocketIO *)socket
  {
      NSLog(@"socket.io connected.");
      NSMutableDictionary *dict2 = [NSMutableDictionary dictionary];
      [dict2 setObject:@"demo1" forKey:@"user"];
      [dict2 setObject:@"php" forKey:@"room"];
      [socketIO sendEvent:@"mjmChatAddUser" withData:@{@"Abc":@"php"}];
  
  
  }
  
  - (void) socketIO:(SocketIO *)socket didReceiveEvent:(SocketIOPacket *)packet
  {
      NSLog(@"didReceiveEvent()");
  
      // test acknowledge
      SocketIOCallback cb = ^(id argsData) {
          NSDictionary *response = argsData;
          // do something with response
          NSLog(@"ack arrived: %@", response);
  
          // test forced disconnect
          [socketIO disconnectForced];
      };
      [socketIO sendMessage:@"hello back!" withAcknowledge:cb];
  }
  
  - (void) socketIO:(SocketIO *)socket onError:(NSError *)error
  {
      if ([error code] == SocketIOUnauthorized) {
          NSLog(@"not authorized");
      } else {
          NSLog(@"onError() %@", error);
      }
  }
  
  
  - (void) socketIODidDisconnect:(SocketIO *)socket disconnectedWithError:(NSError *)error
  {
      NSLog(@"socket.io disconnected. did error occur? %@", error);
  }
  </code></pre>