Class jsstp_t

jsstp object

See

jsstp

Alias

jsstp.type

Example

let my_jsstp=new jsstp.type("my_coooool_jsstp",sstp_server_url);

Hierarchy (view full)

Indexable

[key: `On${string}`]: simple_event_caller

Matches event names to generate a simple invoker

Group

Index reflections

Example

let data=await jsstp.OnTest(123,"abc");

Constructors

  • Basic jsstp object

    Parameters

    • Optional sender_name: String

      The name of the sender when the object interacts with the server

    • Optional host: String

      Target server address

    Returns jsstp_t

Properties

RequestHeader: {
    [key: string]: string;
}

The header used in fecth.

Type declaration

  • [key: string]: string
default_info: base_sstp_content_t

Default Message Content

default_security_level: security_level_t

Queries the default security level, which is "local" in nodejs and "external" in browsers.

proxy: jsstp_t

Self Proxy

sstp_version_table: {
    [method: string]: Number;
}

SSTP protocol version number list

Type declaration

  • [method: string]: Number

Methods

  • Get whether ghost is currently available

    Returns Promise<Boolean>

    whether ghost is available or not

    Example

    if(await jsstp.available())
    //do something
    else
    console.error("Ghost is not available, please check if ghost is running.");
  • Getting fmo information

    Returns Promise<fmo_info_t>

    fmo information

    Example

    let fmo=await jsstp.get_fmo_infos();
    if(fmo.available)
    console.log(fmo);
  • Getting supported events in an agreed structure requires ghost to support Get_Supported_Events events
    If unsure of ghost support, use ghost_events_queryer_t (obtained via jsstp_t.new_event_queryer) to query

    Returns Promise<{
        external: string[];
        local: string[];
    }>

    Object containing both local and external arrays

    Example

    jsstp.get_supported_events().then(result => console.log(result));
    

    Example

    //sample code (AYA):
    SHIORI_EV.On_Get_Supported_Events: void {
    _L=GETFUNCLIST('On')
    _base_local_event_funcs=IARRAY
    foreach _L;_func{
    if SUBSTR(_func,2,1) == '_'
    _func=SUBSTR(_func,3,STRLEN(_func))
    _base_local_event_funcs,=_func
    }
    _L=GETFUNCLIST('SHIORI_EV.On')
    foreach _L;_func{
    if SUBSTR(_func,12,1) == '_'
    _func=SUBSTR(_func,13,STRLEN(_func))
    _base_local_event_funcs,=_func
    }
    SHIORI_FW.Make_X_SSTP_PassThru('local',ARRAYDEDUP(_base_local_event_funcs))
    _L=GETFUNCLIST('ExternalEvent.On')
    _base_external_event_funcs=IARRAY
    foreach _L;_func{
    if SUBSTR(_func,16,1) == '_'
    _func=SUBSTR(_func,17,STRLEN(_func))
    _base_external_event_funcs,=_func
    }
    _L=GETFUNCLIST('SHIORI_EV.ExternalEvent.On')
    foreach _L;_func{
    if SUBSTR(_func,26,1) == '_'
    _func=SUBSTR(_func,27,STRLEN(_func))
    _base_external_event_funcs,=_func
    }
    SHIORI_FW.Make_X_SSTP_PassThru('external',ARRAYDEDUP(_base_external_event_funcs))
    }
    SHIORI_EV.ExternalEvent.On_Get_Supported_Events{
    SHIORI_EV.On_Get_Supported_Events
    }
  • Determine if an event exists
    Use ghost_events_queryer_t (obtained via jsstp_t.new_event_queryer) to query if it is likely to be called frequently

    Parameters

    • event_name: String

      event_name

    • Optional security_level: security_level_t

      security_level

    Returns Promise<Boolean>

    whether or not it exists

    Example

    jsstp.has_event("OnTest").then(result => console.log(result));
    

    Example

    //sample code (AYA):
    SHIORI_EV.On_Has_Event : void {
    _event_name=reference.raw[0]
    _SecurityLevel=reference.raw[1]
    if !_SecurityLevel
    _SecurityLevel=SHIORI_FW.SecurityLevel
    if SUBSTR(_event_name,0,2) != 'On'
    _event_name='On_'+_event_name
    _result=0
    if TOLOWER(_SecurityLevel) == 'external'
    _event_name='ExternalEvent.'+_event_name
    _result=ISFUNC(_event_name)
    if !_result
    _result=ISFUNC('SHIORI_EV.'+_event_name)
    SHIORI_FW.Make_X_SSTP_PassThru('Result',_result)
    }
    SHIORI_EV.ExternalEvent.On_Has_Event{
    SHIORI_EV.On_Has_Event
    }
  • Get a queryer for querying events supported by ghost

    Returns Promise<ghost_events_queryer_t>

    Query the queryer for supported events.

    Example

    jsstp.new_event_queryer().then(queryer => 
    queryer.check_event("OnTest").then(result =>
    console.log(result)
    )
    );

Basic Send Methods

  • Sends the message, but does not process the returned results

    Parameters

    • sstphead: String

      The header of the message.

    • info: Object

      The body of the message.

    Returns Promise<String>

    Returns a promise.

  • Send a custom message

    Type Parameters

    • T

    Parameters

    • sstphead: String

      Message header

    • info: Object

      The body of the message.

    • result_type: (new (str) => T)

      The type of the result, defaults to sstp_info_t

        • new (str): T
        • Parameters

          • str: string

          Returns T

    Returns Promise<T>

    Returns a promise

  • Sends a message in text and receives it back in text

    Parameters

    • info: any

      Message body (text)

    Returns Promise<String>

    Returns a promise.

Caller Methods

  • Get the invoker of a specific method

    Type Parameters

    • T = sstp_info_t
    • Rest extends any[] = [Object]
    • Res = Object

    Parameters

    • method_name: String

      The name of the method

    • Optional result_type: (new (str) => T)

      The type of the result, defaults to sstp_info_t

        • new (str): T
        • Parameters

          • str: string

          Returns T

    • Optional args_processor: ((...args) => Res)

      Argument processor, defaults to returning the input argument directly

        • (...args): Res
        • Parameters

          Returns Res

    Returns method_caller<T, Rest>

    The invoker

Clone Methods

Indexer Members

PromiseLike Methods

  • Get whether ghost is currently available

    Type Parameters

    • result_T = undefined

    Parameters

    Returns Promise<result_T>

    whether ghost is available, if so, resolve with jsstp, otherwise reject.

    Example

    jsstp.if_available(() => {
    //do something
    });

    Example

    xxx.then(v => jsstp.if_available()).then(() => {
    //do something
    });

SSTP Base Methods

Types

base_sstp_info_t: typeof base_sstp_info_t
fmo_info_t: typeof fmo_info_t
ghost_events_queryer_t: typeof ghost_events_queryer_t
list_info_t: typeof list_info_t
sstp_info_t: typeof sstp_info_t
type: typeof jsstp_t

Generated using TypeDoc