Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
RapsFan
Posts: 442
Registered: ‎08-02-2010
My Device: Z10

Project setup for Web Eorkd game with Node.js

Hello everyone. I'm making a multiplayer game with WW and Node.js. So far I have a login.html that connectd to the php on the backend. After logging into the client side game.html connects to the remote node server, however I don't know how to send data back to the client. All the node documentation I've come across has the index.html and the node server running on the same machine. As I understand it the server reads the index.html file on the server, sends the data object back to it then in the .html I get the data object and handle it, but how do I do this in a WebWorks project? 

 

 

fs.readFile('./index.html', function(err, data) {res.end(data);});

 

 

Developer
Developer
LBP
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Project setup for Web Eorkd game with Node.js

You are trying to read a "remote" file using localFileSystem function, this won't work or isn't the right approach I think. You want to send data to a client, so try to create a script on your PHP server that is only sending data and on client-side use XHR to open (GET) this script to receive and handle the data send.

 

In PHP something like

 

<?php
$arr = array('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr);
?>

will return the array in JSON notification so you can reuse it very well in JS on the client-side.

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
RapsFan
Posts: 442
Registered: ‎08-02-2010
My Device: Z10

Re: Project setup for Web Eorkd game with Node.js

I used this for my login, however I'm wondering about how to do GET and POST requests with Node.js as.
Developer
RapsFan
Posts: 442
Registered: ‎08-02-2010
My Device: Z10

Re: Project setup for Web Eorkd game with Node.js

BTW was late when I asked this and I was headin to bed. That's the reason for the embarrasing typo in the topic :smileytongue: