1.0.0 • Published 3 years ago

sr-protocol v1.0.0

Weekly downloads
2
License
ISC
Repository
-
Last release
3 years ago

Send and Return Protocol

This package is for make SRP server / client.

Usage

var express = require("express");
var srp = require("srp");
var app = express();
app.use(srp.server(/*option*/));

Option of require("srp").server()

  • Object
    • path (Optional, default is /) Changes the path where SRP opens.
    • command (Optional, default is {}) Makes the commands.

      Usage:

      {
        command: {
          name: function(socket, args, sockets, response){
            // socket contains socket of sender.
            // args contains arguments of the command.
            // sockets contains all sockets.
            // response contains response of socket.
          }
        }
      }

Format of SRP

SRP uses hex for messages.

  • Request Example:

    &cmd:4d657373616765
    &REM:It's a comment, so it does nothing

    (4d657373616765 means Message in hex)

  • Response Example:

    SRP/0.1 0 SUCCESS
    #ERR:4572726f72
    #REC:5265636569766564206d657373616765

    (4572726f72 means Error in hex) (5265636569766564206d657373616765 means "Received message" in hex)