Page 12 of 28

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

Posted: Fri Jun 08, 2012 4:41 am
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.

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

Posted: Fri Jun 08, 2012 4:50 am
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.

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

Posted: Fri Jun 08, 2012 7:55 am
by Rathinagiri
Ok. I will check and tell. :)

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

Posted: Fri Jun 08, 2012 1:49 pm
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.

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

Posted: Fri Jun 08, 2012 2:11 pm
by Rathinagiri
Yes. I have Apache.

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

Posted: Fri Jun 08, 2012 3:21 pm
by Roberto Lopez
rathinagiri wrote:Yes. I have Apache.
I'm using a nice pre-configured bundle (Apache,PHP and MySql) called 'vertrigo'.

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

Posted: Fri Jun 08, 2012 8:44 pm
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

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

Posted: Sat Jun 09, 2012 2:09 am
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.

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

Posted: Sat Jun 09, 2012 4:35 am
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!

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

Posted: Sat Jun 09, 2012 4:49 am
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?