-
Notifications
You must be signed in to change notification settings - Fork 1
Editor API
TNT Basic’s editor API runs on port 7676 on the local host. A web based client can connect to it via HTTP and upgrade it to a web socket connection. It should request the protocol ‘tb-cmd-protocol’. Once it has this connection, it can send JSON encoded commands over this connection to perform actions on the project files that TNT Basic currently has open for edit.
An example command is:
{"command": "getresource", "projectid" : '+g_projectId+', "type" : "Basc", "id" : 128 }
The key ‘command’ is the name of the command. The commands are listed below. The rest of the keys are parameters for the command. This dictionary should just be written to the websocket as a string.
An example response is:
{ "status":0, "statusstr":"OK", "response":"R2xvYmFsIGZsb2F0CWtGcmljdGlvb...." }
The key ‘status’ indicates whether the command was successful. 0 means it was. ‘statusstr’ is a human readable description of the error. ‘response’ is the result, this will not be present if an error occurred.
The currently supported commands are:
This method will return the contents of a resource from within the project file. The data will be sent binhex encoded (the Javascript client can use btoa to decode it).
projectid (required)
The numeric project ID which TNT Basic provides to the editing web page when it launches it
type (required)
The 4 character string which defines the resource type to get
id (required)
The numeric ID of the resource to get
status
The status code. 0 for OK, or a numeric error.
statusstr
English description of the status code.
response
If no errors occur, the binhex-ed contents of the resource