Class jsstp_t

jsstp object

jsstp

jsstp.type

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

Indexable

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

    Matches event names to generate a simple invoker

    Index reflections

    let data=await jsstp.OnTest(123,"abc");
    
  • [key: `Get${string}`]: simple_list_command_caller

    Matches event names to generate a simple invoker

    Index reflections

    let data=await jsstp.GetNames();
    
  • [key: `Set${string}`]: simple_command_caller

    Matches event names to generate a simple invoker

    Index reflections

    let data=await jsstp.SetCookie("abc","def");
    

Constructors

  • Basic jsstp object

    Parameters

    • Optionalsender_name: String

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

    • Optionalhost: String

      Target server address

    Returns jsstp_t

Properties

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

The header used in fecth.

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

Methods

  • Get whether ghost is currently available

    Returns Promise<Boolean>

    whether ghost is available or not

    if(await jsstp.available())
    //do something
    else
    console.error("Ghost is not available, please check if ghost is running.");
  • Processing of fmoinfo for all ghosts

    Type Parameters

    • result_T

    Parameters

    • operation: ((fmo_info: single_fmo_info_t) => result_T)

      Operator function

    Returns Promise<info_object<string, result_T>>

  • Operate on all ghosts

    Type Parameters

    • result_T

    Parameters

    • operation: ((jsstp: jsstp_with_ghost_info_t) => result_T)

      Operator function

    Returns Promise<info_object<string, result_T>>

  • Getting fmo information

    Returns Promise<fmo_info_t>

    fmo information

    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

    jsstp.get_supported_events().then(result => console.log(result));
    
    //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

    • Optionalsecurity_level: security_level_t

      security_level

    Returns Promise<Boolean>

    whether or not it exists

    jsstp.has_event("OnTest").then(result => console.log(result));
    
    //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.

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

Basic Send Methods

  • Send a custom message

    Type Parameters

    • T

    Parameters

    • sstphead: String

      Message header

    • info: Object

      The body of the message.

    • result_type: (new (str: string) => 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 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.

  • 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 key

    Type Parameters

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

    Parameters

    • key_name: String

      Key name

    • value_name: String

      Key value

    • Optionalmethod_caller: method_caller<T, [Res]>

      Method invoker

    • Optionalargs_processor: ((...args: Rest) => Res)

      Argument processor

        • (...args): Res
        • Parameters

          Returns Res

    Returns base_keyed_method_caller<T, Rest>

    The invoker

  • 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

    • Optionalresult_type: (new (str: string) => T)

      The type of the result, defaults to sstp_info_t

        • new (str): T
        • Parameters

          • str: string

          Returns T

    • Optionalargs_processor: ((...args: Rest) => Res)

      Argument processor, defaults to returning the input argument directly

        • (...args): Res
        • Parameters

          Returns Res

    Returns method_caller<T, Rest>

    The invoker

  • Get a simple invoker for a specific key

    Type Parameters

    Parameters

    • key_name: String

      Key name

    • value_name: String

      Key value

    • Optionalmethod_caller: method_caller<T, [Object]>

      Method invoker

    Returns simple_keyed_method_caller<T>

    The invoker

Clone Methods

  • Copy a new jsstp object for the given fmo_info

    Parameters

    • fmo_info: single_fmo_info_t

      fmo_info of target ghost

    Returns jsstp_with_ghost_info_t

    New jsstp object pointing to target ghost

Indexer Members

  • get command(): {
        [command_name: string]: simple_command_caller;
    }
  • Proxy to get the executor of a specific command

    Returns {
        [command_name: string]: simple_command_caller;
    }

    • [command_name: string]: simple_command_caller
    jsstp.command.GetFMO();
    
  • get event(): {
        [event_name: string]: simple_event_caller;
    }
  • Proxy for a simple caller to get a specified event

    Returns {
        [event_name: string]: simple_event_caller;
    }

    • [event_name: string]: simple_event_caller
    jsstp.event.OnTest("test");
    

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.

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

SSTP Base Methods

COMMUNICATE: method_caller<sstp_info_t, [common_communicate_sstp_content_t]>
EXECUTE: method_caller<sstp_info_t, [common_execute_sstp_content_t]>
GIVE: method_caller<sstp_info_t, [common_give_sstp_content_t]>
NOTIFY: method_caller<sstp_info_t, [common_event_sstp_content_t]>
SEND: method_caller<sstp_info_t, [common_event_sstp_content_t]>

Types

base_sstp_info_t: typeof base_sstp_info_t

Base sstp message class

let info = new jsstp.sstp_info_t("SSTP/1.4 200 OK\r\nCharset: UTF-8\r\nSender: SSTP Client\r\nScript: \\h\\s0Testing!\\u\\s[10]It's a test.\r\nOption: notranslate\r\n\r\n");
console.log(info.head);//SSTP/1.4 200 OK
console.log(info.Option);//notranslate

base_sstp_info_t

fmo_info_t: typeof fmo_info_t

fmo message class

let fmo = jsstp.get_fmo_infos();
let kikka_uuid = fmo.get_uuid_by("name", "橘花");
if(kikka_uuid)
console.log(fmo[kikka_uuid].ghostpath);
ghost_events_queryer_t: typeof ghost_events_queryer_t

ghost event finder

let ghost_events_queryer = jsstp.new_event_queryer();
if(!ghost_events_queryer.available)
console.log("Current ghost does not support event queries");
if(ghost_events_queryer.has_event("OnBoom"))
jsstp.OnBoom();
list_info_t: typeof list_info_t

List message object

let list = jsstp.GetNames();
for(let name of list)
console.log(name);

list_info_t

sstp_info_t: typeof sstp_info_t

sstp message class

let info = new jsstp.sstp_info_t("SSTP/1.4 200 OK\r\nCharset: UTF-8\r\nSender: SSTP Client\r\nScript: \\h\\s0Testing!\\u\\s[10]It's a test.\r\nOption: notranslate\r\n\r\n");
console.log(info.head);//SSTP/1.4 200 OK
console.log(info.Option);//notranslate

sstp_info_t

type: typeof jsstp_t

jsstp object

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