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

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 4023
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:Very good Roberto. It is pretty fast enough.
Yes it is!

There is a lot of work pending on table to (ie) make rows selectable, make the headers fixed, etc., but the important thing is that was probed that the project is possible.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
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:Again a basic doubt.

How can we reach the demo.server.html file from another system (say another machine in the same LAN)?
You must edit server name in the line #25 of demo.server.html, changing localhost by the ip address of the server.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5481
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 »

Ok. I will check and tell. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
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:Ok. I will check and tell. :)
Please, consider that to serve web pages, you'll additionally need an http server.

Websockets server only handles data.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5481
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 »

Yes. I have Apache.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
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:Yes. I have Apache.
I'm using a nice pre-configured bundle (Apache,PHP and MySql) called 'vertrigo'.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
apais
Posts: 440
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF
Location: uruguay
Contact:

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

Post by apais »

In harbour tree there is an http server called uhttp ( micro http )

Now my question:

1) How can we filter the list of callable routines in the ws-server ?
I don't want someone calling quit() or ferase(*.*) from a web page

2) how can we identify sessions of validated users ?

Regards
Angel
Angel Pais
Web Apps consultant/architect/developer.
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

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

Post by Roberto Lopez »

apais wrote:In harbour tree there is an http server called uhttp ( micro http )

Now my question:

1) How can we filter the list of callable routines in the ws-server ?
I don't want someone calling quit() or ferase(*.*) from a web page

2) how can we identify sessions of validated users ?

Regards
Angel
1. There is no a mechanism for that right now, but could be extremely easy to do. Please take a look at the code and you'll figure out.

2. You could ask for a password at user login. Please consider that the session does not exist in the same sense that a session is when http is used. With websockets, once that you connected to the server, you'll stay connected.

I've not analyzed the code deeply, but as I've understood with a brief look, it is multi-threaded, so, you should not care about multiple users.
The server is Harbour, so, you can modify as you want.

Again... the code must be analyzed in detail to be sure how it works, so, some of my preliminary conclusions could be wrong.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
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:
1. There is no a mechanism for that right now, but could be extremely easy to do. Please take a look at the code and you'll figure out.

2. You could ask for a password at user login. Please consider that the session does not exist in the same sense that a session is when http is used. With websockets, once that you connected to the server, you'll stay connected.

I've not analyzed the code deeply, but as I've understood with a brief look, it is multi-threaded, so, you should not care about multiple users.
The server is Harbour, so, you can modify as you want.

Again... the code must be analyzed in detail to be sure how it works, so, some of my preliminary conclusions could be wrong.
This is the 'listen' method of HBSOCKET class.

I'm not an expert on MT, but it looks like a new thread starts with each new connection, so, we must not care for multiple users.

Code: Select all

METHOD Listen() CLASS HBSocket

   ::pSocket     = HB_SocketOpen( )
   ::hMutexUser  = HB_MutexCreate()   

   IF ! HB_SocketBind( ::pSocket, { HB_SOCKET_AF_INET, ::cBindAddress, ::nPort } )
      QOut( ::cError :=  "Bind error " + hb_ntos( HB_SocketGetError() ) )
      HB_SocketClose( ::pSocket )
      RETURN .F.
   ENDIF

   IF ! HB_SocketListen( ::pSocket )
      QOut( ::cError :=  "Listen error " + hb_ntos( HB_SocketGetError() ) )
      HB_SocketClose( ::pSocket )
      RETURN .F.
   ENDIF
      
   if hb_IsBlock( ::bOnListen )
      Eval( ::bOnListen, Self )
   endif
   ::Debug( "LISTEN" )

   hb_ThreadStart( {|| ::OnAccept() } )

   DO WHILE ! ::lExit
   

      inkey( 0.1 )  

      if ::bOnProccess != nil 
         ::lExit = eval( ::bOnProccess, Self )
      else 
         ::lExit := LastKey() == 27
      endif
      
               
   ENDDO    

   ::End()
   
RETURN .T.
Testers are welcome!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5481
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 »

In that case, can we mingle uhttp and websocket server so that we can use single Harbour server to produce both html and data over network?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply