Jump to content
Sign in to follow this  
Ekkas

Noob startup question

Recommended Posts

Hello. I'm first time user of SmartMobileStudio.

I've done my homework and SMS is the way our company want to go forward, away from SQL desktop apps to server/web based apps, especially since 2.0beta is out with networking/server side.

 

I've just bought SMS (I know the trial would have been fine for now) and want to run the node.js Hello world. I installed node.js as either 64 and then (un+install)as 32 bit before executing the demo, but the debug screen just flash past and the server does not run. (I'm on Win7-64)

Can I stop the debug to see any messages of is there a log file somewhere?

What else could be missing to get up and running?

 

Regards

 

Ekkas

Share this post


Link to post
Share on other sites

Thanks for the reply.

On trying to run your -SmartNodeSocketIO- demo, I get this:

 

FMessage: 'Error, Cannot find module \'node-static\''

 

I think I did the setup, I installed node.js (32-bit on Win7-64) and ran the socket-io install command.

 

I extracted the code into folder of my choice and ran it from SMS.

 

Should I copy anything to any shared folders or something?

 

Apologies if I ask silly questions but would like to get the demo up from where I can start to 'play'.

 

Regards

 

Ekkas

 

 

Share this post


Link to post
Share on other sites

There are no silly questions :)

The reason you get this error is because part 4 (of node.js series) isn't published yet but I did the commit already :( My fault...

 

Anyway, you can just install it like you did with socket.io (on the console):

npm install node-static

Share this post


Link to post
Share on other sites

Aha thanks. All this (coming from strict Delphi desktop/Firebird) is new to me, so I do not know where to look. :)

 

I had to do a :

npm install socket-io

as well and now demo is running!

 

 

 

Thank you.

 

Regards

 

Ekkas

Share this post


Link to post
Share on other sites

Yes, the javascript backend (node.js or browser) is much different to "normal" delphi programming, but at least the pascal language in SMS is the same (and even better)

 

So yes, it can take some time to understand how to do stuff in node.js etc, but be aware: it is also very cool and addictive ;)

Share this post


Link to post
Share on other sites

but be aware: it is also very cool and addictive

 

I certainly hope so. :)

 

Well I got the demo running, then running client from SMS.

 

<span style="font-size: 14px; line-height: 1.5em;">http://localhost:8090     - </span>returns 'Hello world'

 

http://localhost:8090/index.html    - returns the progress bars with buttons, but nothing happens when I click.

 

I included line below as some rudimentary debugging, but it does not show new connections.

 

 

 

var value := 0;

var io := socketio().listen(server);

io.sockets.on('connection', //wait for connections

procedure(socket: JSocketIO)

begin

===>>Console.log('New connection');

socket.emit('dataPushed', ['test']); //push some test data to client on connection

Share this post


Link to post
Share on other sites

are you running the client standalone? then change these lines in client:

 

procedure TForm1.InitializeObject;

begin

inherited;

{$I 'Form1:impl'}

FSocket := socketio.connect('http://localhost:80'); standalone test

//FSocket := socketio.connect(''); //cloud test

Share this post


Link to post
Share on other sites

I am not making sense of this... :(

 

In the server app, it says:

var port := 5000;

But the client app says:

FSocket := socketio.connect('http://localhost:80');

and when I run it:

http://192.168.0.2:8090/index.html

The server runs succesfully on port 500o according to console. So how do server port 5000 work with the client app's port 80 in code and 8090 in runtime?

 

I tried to compile the client with port 5000 and 8090 but it did not work in either case. I also tried copying the client www to server public folder each time, and just access server from browser, but everytime I just get the progress bars already filled-up / non-responsive.

 

Edit: I can see something happening on server though:

Server running at http://127.0.0.1:5000

info - socket.io started

http request: /index.html

http request: /app.manifest

http request: /res/app.css

http request: /lib/socketio.js

http request: /app.manifest

http request: /favicon.ico

Regards

 

Ekkas

Share this post


Link to post
Share on other sites

port 8090 is the default debugger port of the SMS IDE.

This is needed in case you don't have a http server (for client web apps).

 

Each node.js server has default a http server, which is configured in this case on port 5000.

To get the client working, you should do one of these options:

1) change the port in the client to 5000 (same as server):

FSocket := socketio.connect(‘http://localhost:5000′);

Now you can run both client and server in SMS IDE.

 

2) copy the client generated sources (www folder) into "\www\public\" folder of the server and change the line in the client to:

FSocket := socketio.connect(”);

But now you can't run the client from the SMS IDE, because it will auto connect to the same host and port as it will run into (so when it's ran in the SMS IDE it will try to connect to localhost:8090 which won't work).

Run the node.js server, and open manually in e.g. Google Chrome:

http://localhost:5000/index.html

Node.js server will now server the client index.html from it's \public\ folder and the client will connect to localhost:5000 for the socket.io communication.

 

You can try to download the full demo from here:

https://github.com/andremussche/AndrewsDelphiStuff/tree/master/NodeJsInSmartMobileStudio/-SmartNodeSocketIO-/www

 

Download the full folder and execute "startnode.bat"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×