Reference: SSTP (external site)
At present, DirectSSTP depends heavily on Windows specifications, and implementation on other operating systems is not anticipated.
Since IPC mechanisms also exist on other operating systems, it would be preferable to define a separate specification.
If a specification is established, we plan to publish it separately, so please contact the Ukadoc Project.
SSTP is a general-purpose communication specification between ghosts. It can be used for simple Sakura Script playback, external event notifications, and similar purposes.
Communication is generally done over TCP/IP. The system listens on port 9801 or 9821 (SSP only). Sending a request according to the SSTP protocol returns the processing result.
For security reasons, unless the settings are changed, it currently listens only on localhost, so communication from outside the device is not possible. Port 11000 was also listened on in the past, but it has since been deprecated because the communication was mistaken for malware activity.
For SSP startup options, including --sstp-listen, which temporarily specifies the listening address at startup, see Startup options in the SSP Help.
7743 and 9801 are registered in the IANA Port Number Registry, but only port 9801 is actually in use.
Microsoft defined a VPN protocol with the same abbreviation, Secure Socket Tunneling Protocol, but it has no technical relation to SSTP.
By default, the connection is closed at the end of each communication. For frequent communication, the connection can be reused with keep-alive, as with HTTP [SSP 2.9.03].
Direct SSTP is a communication specification that uses an IPC mechanism strongly dependent on the operating system. Its protocol specification is the same as (Socket) SSTP, but it is intended to provide lightweight communication by directly specifying a ghost, without using the comparatively resource-intensive TCP/IP.
At present, the specification has been established only for Windows, as follows.
Send WM_COPYDATA using a SendMessage-family function (Post is not allowed)
SendMessage's hWnd = HWND of the destination ghost obtained from FMO
wParam = HWND of “your own” reply destination. The response is received on the HWND (window) specified for WM_COPYDATA.
lParam = pointer to COPYDATASTRUCT
copydatastruct.lpData = string conforming to the SSTP protocol
copydatastruct.cbData = length of the string
copydatastruct.dwData = 9801
Notes:
For safety, the sender should provide a null-terminated string in lpData, and it is preferable for cbData to include the null terminator.
For safety, the receiver must not assume a null terminator and must always process the data based on cbData.
The receiver should treat the HWND specified as the destination as equivalent to the ghost specified in the SSTP protocol, and prioritize that ghost as much as possible.
Both the receiver and sender are assumed to be GUI applications with at least one window; this cannot be used with console applications.
SAORI/1.0 requests can also be sent in the same way to call a baseware built-in module. See SAORI over DirectSSTP.[SSP 2.9.13]
SSTP over HTTP, implemented in SSP 2.6.32, is a very simple mechanism: an SSTP request is placed directly in the HTTP request message body, and the SSTP response is returned directly in the HTTP response body.
It is intended to make SSTP communication easier when building applications with JavaScript, such as Electron.
Send an HTTP/1.1 POST request with Content-Type: text/plain to localhost:9801 (or a separately specified SSTP port), at /api/sstp/v1.
The response is returned as-is with HTTP/1.1 200 OK and Content-Type: text/plain.
Note that HTTP returns 200 OK even if SSTP encounters an error.
The Content-Length header is required; if it is missing, an error occurs.
HTTP keep-alive is supported. In HTTP/1.1, the connection is maintained by default and closed with Connection: close (for HTTP/1.0, it is maintained only when Connection: keep-alive is specified explicitly). Connections are not maintained for requests with Transfer-Encoding (such as chunked). In this case, connection persistence is determined only by the HTTP settings, and the SSTP Connection header in the message body is ignored [SSP 2.9.03].
Existing js libraries can be used to communicate via SSTP over HTTP in js.
Note: If the Origin header does not point to localhost, the request is forcibly treated as an SSTP request from a remote address. This imposes strong restrictions on Sakura Script tags and executable SSTP methods, and the SecurityLevel header is also ignored.
These restrictions are relaxed only when the HTTP Origin is localhost and the SSTP SecurityLevel is local.
Starting with SSP 2.9.03, (Socket) SSTP supports sending multiple requests consecutively over a single TCP connection using keep-alive, just like HTTP [SSP 2.9.03].
This avoids the overhead of establishing a connection, making it suitable for clients that send SSTP repeatedly at short intervals.
Connection: keep-alive header (the same explicit opt-in as HTTP/1.0). If it is not included, the connection is closed after the response as before, and the response content is unchanged.Connection: keep-alive and Keep-Alive: timeout=seconds are returned, the connection is being kept alive.Connection: close is returned, the connection is closed after the response (for example, when the maximum number of simultaneous connections has been reached).EXECUTE SSTP/1.4
Charset: UTF-8
Sender: SSTPクライアント
Command: GetVersion
Connection: keep-alive
SSTP/1.4 200 OK
Charset: UTF-8
Connection: keep-alive
Keep-Alive: timeout=5
Content-Length: 24
追加データはここ
SSTP/1.4 204 No Content
Charset: UTF-8
Connection: close
Like SHIORI and other protocols, this is a custom protocol modeled on HTTP.
The request must specify a Charset. If omitted, an error occurs or the request is interpreted using the OS default character encoding.
SEND SSTP/1.0
Charset: UTF-8
Sender: SSTPクライアント
Script: \h\s0テストー。\u\s[10]テストやな。
Option: notranslate
For method-specific headers, see the descriptions of individual methods below.
\0 name.\s), animations (\i), or balloons (\b); unknown tags, \![コマンド], or \&[実体参照]; missing required [] or numbers; and invalid values for \p, \b, \n, \c, or \q. Applies to SEND scripts and scripts returned by a ghost for NOTIFY/GIVE [SSP 2.8.94]\t.\0 of the ghost to which the request should be sent.\0 name of the ghost to which the request should be sent.SSTP/1.4 200 OK
Charset: UTF-8
Script: \h\s0テストー。\u\s[10]テストやな。
SSTP/1.4 200 OK
Charset: UTF-8
Script: \h\s0テストー。\u\s[10]テストやな。
追加データはここ
As with HTTP, 200-series codes indicate successful acceptance; all others indicate errors.
\t tag or similar, or another request is being processedThis method notifies a ghost of an event.
SEND and NOTIFY are handled identically and have no functional differences. For details about shared headers and routing rules for IfGhost, see Method: SEND.
The Event header corresponds to the SHIORI/3.0 ID, and Reference* is passed through unchanged.
NOTIFY SSTP/1.0
Charset: UTF-8
Sender: Media Player
Event: OnMusicPlay
Reference0: 自由の翼
Reference1: Linked Horizon
If the ghost does not respond to the specified event ID, you can specify a “fallback” script to be played instead.
When an IfGhost header is specified, the Script header immediately after it is treated as a script exclusively for the specified ghost.
NOTIFY SSTP/1.1
Charset: UTF-8
Sender: Media Player
Event: OnMusicPlay
Reference0: 紅蓮の弓矢
Reference1: Linked Horizon
IfGhost: Emily,Teddy
Script: \0\s[6]その日、エミリは思い出した…\n\s[7]まだ今日は芋食べてない!\1\s[11]わざわざ今思い出したの?
IfGhost: ラーシェ,ティセ
Script: \0\s[3]巨人っていっても、身長は列車数両分しかないよね。\1\s[14]それが縦に立ち上がるとさすがに大きいと思うけどね。
For details about the shared headers Event, Reference*, Script, IfGhost, Ghost, and others, see Method: SEND.
SEND is a method for sending Sakura Script or SHIORI events from an external application to a ghost for playback.
SEND and NOTIFY are handled identically. There is no functional difference between them. The following specifications also apply to NOTIFY.
Both specifying Sakura Script directly in the Script header and sending an event in the Event header to obtain a script from the SHIORI response are supported.
Event and Script can be used together. If the SHIORI response to the Event does not return a script, the script in the Script header is used as a fallback.
If no target ghost is specified, the currently running ghost is targeted.
SEND SSTP/1.4
Charset: UTF-8
Sender: SampleApp
Script: \h\s[0]こんにちは。\w5\u\s[10]ご機嫌いかが?\e
SEND SSTP/1.4
Charset: UTF-8
Sender: SampleApp
Event: OnExternalEvent
Reference0: param1
Reference1: param2
SEND SSTP/1.4
Charset: UTF-8
Sender: SampleApp
Event: OnCustomEvent
Reference0: data
Script: \h\s[0]イベント未対応時のスクリプト\e
By specifying multiple IfGhost headers and pairing them with corresponding Script headers, different scripts can be specified for each ghost.
SEND SSTP/1.4
Charset: UTF-8
Sender: SampleApp
Script: \h\s[0]こんにちは。\e
IfGhost: まゆら
Script: \h\s[0]まゆらさん、こんにちは。\e
IfGhost: 花ちゃん,妹
Script: \h\s[0]花ちゃんと妹さん、こんにちは。\e
SEND SSTP/1.4
Charset: UTF-8
Sender: SampleApp
Script: \h\s[0]割り込まないで追加。\e
Option: nobreak
Sender: First can be used as a special value for SEND/NOTIFY. When specified, it targets the ghost (sakura) from the first startup.\0 side name,\1 side name, the immediately following Script header is treated as exclusive to that ghost.By specifying multiple IfGhost headers and pairing them with corresponding Script headers, different scripts can be specified for each ghost.
IfGhost and Script headers are paired in order of appearance. A Script specified before the first IfGhost becomes the default script.
\0 side name,\1 side name", both names must match.\0 side name", the script is selected based on a match of the \0 side name alone.==), the script is selected by matching the ghost's UUID rather than its names. If multiple ghosts with the same UUID are running, the displayed ghost takes priority.The COMMUNICATE method lets you provide a ghost with an arbitrary string from outside and make it respond.
This is basically the same as a response to text entered in the ghost's internal communicate box, but because this is SSTP, the ghost may not accept it.
COMMUNICATE SSTP/1.1
Charset: UTF-8
Sender: User
Sentence: おはよう。
Communicate messages can be sent and received repeatedly between SSTP servers (≈ ghosts).
When sending through Reference0 in a SHIORI/3.0 response, the SSTP message is sent after Sakura Script playback has finished.
This makes it possible to set up behavior that makes ghosts running at the same time appear to be conversing.
COMMUNICATE SSTP/1.2
Charset: UTF-8
Sender: Emily
HWnd: 28236
Sentence: \0\s[5]ちゃっらーん!エミリでーす!\nボクのお腹にはまだ若干の余裕が…?\1\s[11]そんなこと言ってたらまた太るよ?
Surface: 5,11
Reference0: 芋ちょうだい
Reference1: たくさんちょうだい
Reference2: 今すぐちょうだい
\0 and \1 at the time the sending ghost sends the communicate message (≈ when script execution ends).\1 speaks the contents of Sentence. ※Not implemented in SSPThe EXECUTE method retrieves various information about a ghost and executes various commands without using Sakura Script.
The ghost does not speak when this method is executed, but its internal state may change.
EXECUTE SSTP/1.1
Charset: UTF-8
Sender: SSTPクライアント
Command: GetName
See below for the strings that can be specified in the Command header and the results returned as additional data in the response.
\0 name),(\1 name), separated by a comma.\0 names of currently installed ghosts, separated by newlines and terminated by an empty line.uuid in the property system).master). If neither is present, the entry is an empty line..7z, the format is 7z; otherwise, it is ZIP (even if .lzh or .cab is specified, the contents are ZIP). Hidden files and folders are excluded./ separators can also be used).--event= is specified, the failure event (OnCompressArchiveFailure or the identifier with Failure appended) occurs with invalid parameter). Previously, passing a file path caused compression to fail with file not found... is specified as the destination, it is rejected if the resolved path is outside folders managed by SSP (previously, extraction outside managed folders was possible)./ separators can also be used).\![execute,dumpsurface].\![moveasync] without using Sakura Script. Parameters are specified in the same way as in the Sakura Script version.\![set,tasktrayicon] without using Sakura Script. Parameters are specified in the same way as in the Sakura Script version.\![set,trayballoon] without using Sakura Script. Parameters are specified in the same way as in the Sakura Script version.[Legacy specification] This method provides a ghost with various types of data for processing or to elicit a response.
This is a very old specification, and there is no reason to use it now. Use NOTIFY or COMMUNICATE instead.
GIVE SSTP/1.1
Charset: UTF-8
Sender: SSTPクライアント
Document: まず水や。それから粉やな。
GIVE SSTP/1.1
Charset: UTF-8
Sender: SSTPクライアント
Song: 佐世保の時雨