HMGSCRIPT 2012: Programming For The Web in The Right Way :)

Moderator: Rathinagiri

User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Rathinagiri »

Nice conceptual framework. Thanks Roberto. Take rest. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Rathinagiri »

Hi Roberto,

I have modified the server source code to adapt HMG GUI for starting and stopping the server by replacing '?'s with MsgInfo() and removal of Unix platform definitions.

When sending the message, it says 'Can't send the message'. However, when I stop the server, 'Connection closed' message is shown in browser window.

I have attached the HMG project folder.

FYI, std.ch and set.ch files are to be there in the folder of wssocket.exe since I have installed hmgscript in D:
Attachments
hmgsrc.zip
(38.27 KiB) Downloaded 254 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4012
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

rathinagiri wrote:Hi Roberto,

I have modified the server source code to adapt HMG GUI for starting and stopping the server by replacing '?'s with MsgInfo() and removal of Unix platform definitions.

When sending the message, it says 'Can't send the message'. However, when I stop the server, 'Connection closed' message is shown in browser window.

I have attached the HMG project folder.

FYI, std.ch and set.ch files are to be there in the folder of wssocket.exe since I have installed hmgscript in D:
I'm not able even to build it.
Cannot open mt.prg, assumed external
How do had done it?
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4012
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

Hi All,

Please take care of the following:

If you connect() and immediately call SendMessage() function, it could not work, since SendMessage() does not check that the connection be already established.

It works fine on the demo, because sending the message is done by hand, clicking a button and giving enough time to the browser to get the connection process done.

I'm working on it (tomorrow:) ).
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4012
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

And....

I'll stop HMGSCRIPT GUI development for some time.

I must research and learn more about websocket and JavaScript to make a better communication system to solve the issues I've pointed in the previous post.

Meanwhile, please feel free to contribute code for new widgets, helper functions or whatever yo want to do.

If you decide to do it, please, use the hmgscript.contrib.js file. This way we can integrate our work and mine (I'll work on hmgscript.core.js).

One of the beauties of this project, is that we all can work independently, since we are doing on top of DOM, so, we can have, even various (different) ways to create the same widgets and all them can be accessed the same way to manage their properties, events and methods.

Moreover, if someone has some code or suggestions to enhance websockets communication, please notice me, I'll be very happy of save research time on that.

Thanks to all for your support.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4012
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

Roberto Lopez wrote:Hi All,

Please take care of the following:

If you connect() and immediately call SendMessage() function, it could not work, since SendMessage() does not check that the connection be already established.

It works fine on the demo, because sending the message is done by hand, clicking a button and giving enough time to the browser to get the connection process done.

I'm working on it (tomorrow:) ).
I'm still working today because I was not able to stop thinking about it :)

I've solved the problem, but the solution is not very programmers-friendly.

The solution is to add an event listener for the onmessage event. This way you must define which function will be automatically executed when a message arrives and then process the received message within it.

That is very counter-intuitive, I know, but that is the only solution that I've found to make it work in a reliable way.

I'll continue testing and publish it soon.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4012
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

HMGSCRIPT R007

We are ready to go!

The communication system is reliable and it is finished now.

I've changed the sendMessage() function this way:

SendMessage( cMessage , ListenerFunctionName )

where ListenerFunctionName is the name of the function that will be executed automatically when the response arrives to your web browser (please take a look at the server demos).

The response will be stored in the server_response variable.

Besides that, I've modified the server to convert to character the result of the macro-substituted messages sent to the client browser.

EDIT: It was tested with CROME 19.0.1084.52
HMGSCRIPT 2012 FUNCTION REFERENCE (R007)


WINDOW:

Element: DIV

You can use all the properties, events and methods availables for it via DOM.

Syntax:

Window( cId , cCaption , nWidth , nHeight )



BUTTON:

Element: INPUT (Type: BUTTON)

You can use all the properties, events and methods availables for it via DOM.

Syntax:

Button( cId , cParentId , nRow , nCol , cCaption , cOnClick )



LABEL:

Element: SPAN

You can use all the properties, events and methods availables for it via DOM.

Syntax:

Label( cId , cParentId , nRow , nCol , cValue )



TEXTBOX:

Element: INPUT (Type: TEXT)

You can use all the properties, events and methods availables for it via DOM.

Syntax:

TextBox( cId , cParentId , nRow , nCol , cValue )



IMAGE:

Element: IMAGE

You can use all the properties, events and methods availables for it via DOM.

Syntax:

Image( cId , cParentId , nRow , nCol , cSrc )



MSGINFO:

Syntax:

MsgInfo( cMessage , cCaption )



RELEASE:

Releases a window.

Syntax:

Release( cId )


CONNECT:

Creates a websocket connection.

Syntax:

Connect()


SENDMESSAGE:

Send a message to a websocket server via the current open connection.

Syntax:

SendMessage( cText , eventlistener )


Eventlistener is the name of the function that will be automatically executed
when the response be received.

The response will be stored in the server_response global variable.



DISCONNECT:

Closes a websocket connection.

Syntax:

Disconnect()
Enjoy!
Attachments
hmgs007.zip
(599.94 KiB) Downloaded 304 times
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by jparada »

Hola,

Tratando de hacer los test, ejecuto como administrador wssocket.exe y lo tengo habilitado en el firewall, y siempre recibo "connection closed from the server", mi ambiente es Google Chrome bajo Windows 7 64bits.

Algún tip...?.

Gracias.

Saludos,
Javier
User avatar
Roberto Lopez
HMG Founder
Posts: 4012
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by Roberto Lopez »

jparada wrote:Hola,

Tratando de hacer los test, ejecuto como administrador wssocket.exe y lo tengo habilitado en el firewall, y siempre recibo "connection closed from the server", mi ambiente es Google Chrome bajo Windows 7 64bits.

Algún tip...?.

Gracias.

Saludos,
Javier
Primero debes presionar el botón connect.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Post by jparada »

Hola Roberto,

Gracias por contestar.

Sucede que el mensaje "connection closed from the server", me aparece precisamente al presionar el botón connect.

Alguna otra sugerencia...?.

Gracias.

Saludos,
Javier
Post Reply