SNP 1 - fullphat/snarl_network_protocol GitHub Wiki
Overview
SNP 1 provides very basic access to the Snarl API. There are two variations: 1.0 and 1.1. SNP 1.0 was introduced in Snarl 2.0 and SNP 1.1 added further functionality in Snarl 2.3.
Other Metrics
Default Port
SNP 1 utilises TCP 9887. While some applications may allow other ports to be used, older applications may be restricted to this port.
Text Encoding
Content values should be encoded as plan ASCII. Characters outside of the standard ASCII range should not be used.
Development on SNP 1 has now ceased and both versions are considered deprecated, applications should be migrated to use the latest iteration of the protocol wherever possible.
Message Structure
SNP 1 only defines Request and Response messages. Signals are not supported.
Request
An SNP 1 request is a single line terminated by a \r\n
pair. The request consists of one or more entries, separated using a #?
pair of characters. Each entry is then split into a key/value pair using a single =
, as follows:
key=value#?key=value#?key=value\r\n
Each entry must contain a key and value; valueless keys are not permitted. Case is also important, especially when it comes to key names and mandatory values. Each request must contain the following:
Entry | Details |
---|---|
type |
The type of request (always SNP ) |
version |
The sub version number (either 1.0 or 1.1 ) |
action |
The action to perform |
For all actions other than version
, the following must also be included:
Entry | Details |
---|---|
app |
The application the action refers to |
Example
type=SNP#?version=1.1#?action=register#?app=My Cool App\r\n
Response
An SNP 1 response is a single line of information separated by forward slashes:
SNP/{version}/{status code}/{status text}[/{data}]
Example
The following indicates success with returned value of 404
:
SNP/1.1/0/OK/404
Utilities and Libraries
(Snarl Net Cmd) is a small .net 2.0 command-line application that uses SNP 1.1 to communicate with Snarl.
Actions
register
Registers an application with Snarl. The same application cannot be registered twice – attempting to do so will result in an error.
Required Entries
Entry | Details |
---|---|
action |
Must be register |
app |
Name of the application being registered |
Example
type=SNP#?version=1.1#?action=register#?app=My Cool App\r\n
add_class
Adds an event class to a previously registered application.
Required Entries
Entry | Details |
---|---|
action |
Must be add_class |
app |
Name of the application being registered |
class |
Name of the event class being added |
Example
type=SNP#?version=1.1#?action=add_class#?app=My Cool App#?class=Event1\r\n
notification
Generates a notification using a previously registered application and class.
Required Entries
Entry | Details |
---|---|
action |
Must be notification |
app |
Name of the registered application |
class |
Name of the event class to use |
Optional Entries
Entry | Details |
---|---|
title |
|
text |
|
timeout |
|
icon |
(SNP 1.1 only) |
default_ack |
(SNP 1.1 only) |
Example
type=SNP#?version=1.1#?action=notification#?app=My Cool App#?class=Event1#?title=Some title#?text=Hello, world!
unregister
Removes the registration of an application from Snarl.
Required Entries
Entry | Details |
---|---|
action |
Must be unregister |
app |
Name of the application being unregistered |
Example
type=SNP#?version=1.1#?action=unregister#?app=My Cool App\r\n
version
(SNP 1.1 Only)
Queries the version of Snarl running. If successful, returns the API version of Snarl.
Required Entries
Entry | Details |
---|---|
action |
Must be version |
Example
type=SNP#?version=1.1#?action=version
Security
SNP 1 does not support authorisation or encryption.