Network functions: OpenConnection()

Report any Hollywood bugs here
Post Reply
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Network functions: OpenConnection()

Post by jalih »

If OpenConnection() can't establish connection, currently Hollywood application is terminated with a dialog window telling: The following network error occured: connection refused.

I think better approach would be just to return the status and possible error string:

Code: Select all

success, error$ = OpenConnection(1, "hostname", 2000)
and let user handle the connection error without quitting the application.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Network functions: OpenConnection()

Post by airsoftsoftwair »

That's a flaw in the Hollywood design. I chose not to implement return codes when I started writing Hollywood because I wanted to save the programmer from the hassle of constantly having to check error codes. That's why all other functions like OpenFile(), LoadBrush() etc. do not return error codes either. The only way to check for error codes is to disable automatic error handling via

Code: Select all

ExitOnError(False)
OpenConnection(1, ...)
error = GetLastError()
ExitOnError(True)
This is pretty much overhead. I'm working on a better solution, though, because some other users have complained about the error handling as well :)
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: Network functions: OpenConnection()

Post by jalih »

Thanks, that works fine as a solution.

Now I just have to write the server part for my game and clean up the code a bit before making sources available for others to play with...
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: Network functions: OpenConnection()

Post by djrikki »

Yeah, thats why I keep creating base object functions to replace/enhance the standard set - so I don't have to keep specifying ExitOnError() everywhere... although I can't get really get away from it!

E.g. A typical example in a multi-windowed environment, Hollywood will gracefully fail if a window isn't open that you are trying to close - ideally I want to do check beforehand via GetAttribute() - but cannot do this either because Hollywood will gracefully fail.

Code: Select all

Function base:CloseWindow(window)
     ExitOnError(False)
     CloseWindow(window)
     ExitOnError(True)
EndFunction
If GetAttribute(#DISPLAY,#AWINDOW,#ATTRSTATE) = #DISPSTATE_OPEN ; even though I am using a conditional IF...ENDIF structure Hollywood still throws a wobbly.
....
EndIf
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
Post Reply