javascript - Running Node.js on iOS as a server and let other device connected in -


i building card game app on ios , android following logic:

  1. people download app app store / google play
  2. they can play game offline other players within same wifi-network
  3. one client act server, while other players act clients
  4. the game app node.js, sqlite embedded
  5. each player's move saved in server
  6. when there's internet access, ios act server send data cloud

my approach is

  1. the game html5 node.js, player act game holder(server) open port (like port 80)

  2. other players use http get/set send , receive json package , game holder

my questions is

  1. will possible me run node.js on ios, server , open ports let other players connect in? can use json communications between players.

  2. if not, best way different device (ios, android, windows phone) communicate?

any suggestions , appreciated. thanks. michael

my reputation not enough comment suggest use anyway. if make server in node.js, rest of answer tell do. use cfnetwork , corefoundation. assuming sending data in string format, code should (the code sends string server).

    import corefoundation     import cfnetwork      var outputstream: nsoutputstream!      var writestream: unmanaged<cfwritestreamref>?      var addr: cfstring = "127.0.0.1"      var port: uint32 = 80      //the second nil in cfstreamcreatepairwithhost read stream. means reads data. don't need bc sending data      cfstreamcreatepairwithsockettohost(nil, addr, port, nil, &writestream)         outputstream = writestream!.takeretainedvalue()          outputstream.delegate = self          outputstream.open()          outputstream.write("firegun", maxlength: 8 //(the char count of firegun")         //close outputstream         outputstream.close() 

Comments

Popular posts from this blog

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -