SNP 1

Introduction

SNP 1 was the initial version of SNP and provides basic access to the Snarl API.  SNP 1.0 was introduced in Snarl x.x and SNP 1.1 added further functionality in Snarl 2.3.  There are two variations: 1.0 and 1.1.

Development on SNP 1 is now ceased and the version is considered deprecated, however it is still supported by Snarl and will be for the foreseeable future.

Message Structure

Request Structure

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.  Each entry is then split into a key/value pair using a single ‘equals’ sign, 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 mandatory entries:

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

  • app – the application the action refers to

Example

type=SNP#?version=1.1#?action=register#?app=My Cool App\r\n

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

  • 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

  • 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

  • action: must be notification
  • app: name of the application being registered
  • class: name of the event class being added

Optional Entries

  • 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

  • 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 (1.1 Only)

Queries the version of Snarl running.  If successful, returns the API version of Snarl.

Required Entries

  • action: must be version

Example

type=SNP#?version=1.1#?action=version

Response Structure

An SNP 1 response is a single line of information separated by forward slashes:

SNP/<version>/<status code>/<status text>[/<data>]

 

Example

SNP/1.1/0/OK/404

 

 

Further Reading

Snarl Net Cmd

Snarl Net Cmd is a small .net 2.0 command-line application that uses SNP 1.1 to communicate with Snarl.