Loading...
 

CX_WEB_SERVICE_MANAGER::OpenMorphITConnection

CX_WEB_SERVICE_MANAGER::OpenMorphITConnection

186192

Description:

Opens a web socket connection to the specified MorphIT server. Only after successful registration with the MorphIT server can Web widgets be used natively and, depending on the server configuration, incoming MorphIT connections can also be bound to this instance.

This call returns immediately and does not wait for a successful registration. Once the instance has successfully registered with the MorphIT server, HasMorphITConnection returns TRUE. Once OpenMorphITConnection has been called, further calls are ignored. To change the target server, CloseMorphITConnection must first be called to terminate an existing connection or a connection attempt.

If the server is not reachable or does not accept the connection, ClassiX tries to re-establish the connection to the server every 10 seconds. The same happens if the server terminates an existing connection.

Code example:

Define(StartMorphITAutomatically)
  g_minorVersion 186191 > if {
    LocalVar(host, port, ssl, endpoint)

    "CX_MORPHIT_PORT" SystemObject Call(GetEnvironment) Dup -> port Cardinality ifnot { (-1) return }
    "CX_MORPHIT_HOST" SystemObject Call(GetEnvironment) Truncate Dup -> host Cardinality ifnot { (-1) return }
    "CX_MORPHIT_SSL"  SystemObject Call(GetEnvironment) Integer if TRUE else FALSE -> ssl
    "CX_MORPHIT_ENDPOINT" SystemObject Call(GetEnvironment) Truncate Dup -> endpoint Cardinality ifnot { "/" -> endpoint } //Use default endpoint

    ssl host port endpoint webServiceManager Call(OpenMorphITConnection)
    0
  }
;

Stack
Stack Position Object type Brief description
Stack(In) Top STRING The web socket endpoint (Ex: "/")
top one INTEGER The port on which the server accepts web socket connections (HTTP port)
top two STRING The hostname/IP of the server to which the connection is to be established
top three INTEGER (TRUE/FALSE) Specifies whether the connection should be established encrypted via SSL (TRUE) or not (FALSE)
Stack(Out) Top
Function call: Call(OpenMorphITConnection)