Jump to content

SmartCL.Time contains routines unavailable in Node.JS

Recommended Posts

Inclusion of the SmartCL.Time unit in a NodeJS project fails to run.

My work around was to comment the code in procedure InitAnimationFrameShim(), as it doesn't seem appropriate here (at least in the Node.JS context). My assumption is that SmartCL.Time is meant to be a shared unit across web browser and Node.JS projects.


[info] Program starting

      return  window.requestAnimationFrame       ||


ReferenceError: window is not defined

    at C:\Smart\Projects\Projects\xxx\output\xxx.js:5467:7

    at InitAnimationFrameShim (C:\Smart\Projects\Projects\xxx\output\xxx.js:5474:7)

    at Object.<anonymous> (C:\Smart\Projects\Projects\xxx\output\xxx.js:6031:1)

    at Module._compile (module.js:643:30)

    at Object.Module._extensions..js (module.js:654:10)

    at Module.load (module.js:556:32)

    at tryModuleLoad (module.js:499:12)

    at Function.Module._load (module.js:491:3)

    at Function.Module.runMain (module.js:684:10)

    at startup (bootstrap_node.js:187:16)

[info] Program stopped


Share this post

Link to post
Share on other sites

Why are you using SmartCL.* named units under node.js?

SmartCL is the visual namespace and the units prefixed "SmartCL" must never be used in non-visual applications.

The only units you can use under node is System.*, SmartNJ.* and the raw NodeJS units.
Never mix visual and non visual namespaces.

What you are looking for is "System.Time", which provides universal code.
Notice that the same unit names exist in different namespaces. System however is fundamental and only contains code that works everywhere :)

Share this post

Link to post
Share on other sites

Thanks for clarifying that. I was unsure of that fact.

I hit this in relation to my other post, trying to reuse my frontend code which used SmartCL.Net.http and SmartCL.Net.REST. Clearly from your reply I shouldn't be trying to do that either.

Perhaps your answer to my other post will solve all these issues. 


Thanks for your quick reply.


Share this post

Link to post
Share on other sites

Yes, im afraid that wont work. If you want to push a http request to a node server, then you want to use the http server class in the SmartNJ.* namespace.
We have tried to make this as "Delphi like" as possible, although its not always possible (or prudent) to handle everything with classic event handlers under JS.
But at least its easy to create a normal http server.

Personally I use websocket. Node has full support for it and all browsers supports it.
It allows you to send both binary and text messages that is cached properly so they arrive in the correct order.
Things like size etc. is dealt with by the stack - and its extremely low latency compared to traditional client/server models.

Just make sure you stick to Node.js 6.9.1 since we havent yet reached node.js in our update plans.
We started with the visual namespace since that needed the most work, and we are gradually getting closer to node now.
There has been a change in how node.js handles events - so "event-emitter" class-defs need to be updated.
Its not a huge thing, but newer versions of node will dump out some error warnings that it uses fallback code and that you need to use the new prototypes.
This will be updated when we are done with the visual stuff -- Im very excited about node.js myself so im looking forward to brushing up on it.

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