Smart Mobile Studio
  • News
  • Forums
  • Download
  • Store
  • Showcases
    • Featured demos
    • The Smart Contest 2013, Round 1 – Graphics
  • Documentation
    • Get the book
    • System requirements
    • Prerequisites
    • Getting started
      • Introduction
      • Application architecture
      • The application object
      • Forms and navigation
      • Message dialogs
      • Themes and styles
    • Project types
      • Visual project
      • Game project
      • Console project
    • Layout manager
    • Networking
      • TW3HttpRequest
      • TW3JSONP
      • Loading files
  • About

Server-side Node.js (part 1): Introduction

Posted on 04.01.2014 by AndreM Posted in Documentation, News

Node.js Logo

In the new version 2 of Smart Mobile Studio you can now create server side projects! This is possible by using node.js, which is “the next big thing”: It’s an event based server side JavaScript application using the open source and very fast Google’s V8 engine. It was initially developed to be used as a HTTP server in the cloud, but nowadays you can also use it on your own PC or on a business server. It is powered by a small executable (6 MB)V8_JavaScript_engine_logo which doesn’t need an installation. Still, it can be extended easily via the package manager npm to fulfill any desired purpose and make it versatile in a lot different situations. For example, it is used by LinkedIn, WalMart and even Microsoft(!) in the Azure cloud. Also, PayPal has recently switched from Java to Node.js…

When you start using node.js, be aware that it is very different to web browser programming: it is a server with no GUI, so no ‘document’ and ‘window’ globals and no ‘alert’ function. It doesn’t run in a sandbox so you access all files, databases etc like you can with a normal application. It has it’s own API for this, which cannot be compared to “JavaScript for HTML”: it is just JavaScript and has nothing to do with web browsers.

But be aware: it is fun and addictive! 🙂

Enough theory, let’s create a new server project in Smart Mobile Studio 2. After you start the IDE we click on the upper left “New…” button. In the projects window we select “Node.js project (server)”:

We close the dialog using the OK button and we have our own “Hello world” demo ready :).

In this demo, we create a new HTTP server, which listens on port 80. For each connection an anonymous method is run which only responds (by closing the response) with the famous (?) “hello world” text. Because node.js runs in a console, we can only show some debug text using “Console.log”.

Let’s run! Press F9 or the “Execute” button to run the server.
(note: when you get “ShellExecute failed with error code 2” you need to install node.js: http://nodejs.org/download/)

Now, start your browser and go to http://localhost:

:

Simple isn’t it? 🙂

« Smart Mobile Studio 2.0 beta 2
Server-side Node.js (part 2): Real-time duplex communication »

Pages

  • About
  • Feature Matrix
  • Forums
  • News
  • Release History
  • Download
  • Showcases
    • The Smart Contest 2013, Round 1 – Graphics
  • Store
  • Documentation
    • Creating your own controls
    • Debugging, exceptions and error handling
    • Differences between Delphi and Smart
    • Get the book
    • Getting started
      • Introduction
      • Local storage, session storage and global storage
      • Application architecture
      • The application object
      • Forms and navigation
      • Message dialogs
      • pmSmart Box Model
      • Themes and styles
    • Layout manager
    • Networking
      • Loading files
      • TW3HttpRequest
      • TW3JSONP
    • Prerequisites
    • Real data, talking to sqLite
    • System requirements
    • Project types
      • Visual project
      • Game project
      • Console project

Archives

  • December 2019
  • December 2018
  • November 2018
  • July 2018
  • June 2018
  • February 2018
  • September 2017
  • April 2017
  • November 2016
  • October 2016
  • September 2016
  • April 2016
  • March 2016
  • January 2016
  • October 2015
  • September 2015
  • July 2015
  • April 2015
  • January 2015
  • December 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • November 2011
  • October 2011
  • September 2011

Categories

  • Announcements (25)
  • Developers log (119)
  • Documentation (26)
  • News (104)
  • News and articles (16)

WordPress

  • Register
  • Log in
  • WordPress

Subscribe

  • Entries (RSS)
  • Comments (RSS)
© Optimale Systemer AS