Skip to content

Communication library for performing http(s) request and opening websockets

License

Notifications You must be signed in to change notification settings

lachrist/channel-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Antena

Receptor

receptor = require("antena/receptor")(options)

  • options :: object
    • onrequest(method, path, headers, body, callback)
      • method :: string
      • path :: string
      • headers :: {string}
      • body :: string
      • callback(status, reason, headers, body)
        • status :: number
        • reason :: string
        • headers :: {string}
        • body :: string
    • onconnect(path, websocket)
      • path :: string
      • websocket :: antena.Websocket
  • receptor :: antena.Receptor

receptor2 = receptor1.merge(receptors)

  • receptor1 :: antena.Receptor
  • receptors :: {antena.Receptor}
  • receptor2 :: antena.Receptor

receptor2 = receptor1.trace(name)

  • receptor1 :: antena.Receptor
  • name :: string
  • receptor2 :: antena.Receptor

handlers = require("antena/receptor/handlers-server")(receptor)

  • receptor :: antena.Receptor
  • handlers :: object
    • request(request, response)
      • request :: http.IncomingMessage
      • response :: http.ServerResponse
    • upgrade(request, socket, head)
      • request :: http.IncomingMessage
      • socket :: net.Socket
      • head :: Buffer

handlers = require("antena/receptor/handlers-webworker")(receptor)

  • handlers(object)
    • message(message)
      • message :: *
    • terminate()

Emitter

emitter = require("antena/emitter/node")(host)

  • host :: string
  • emitter :: antena.Emitter

emitter = require("antena/emitter/browser")(host)

  • host :: string
  • emitter :: antena.Emitter

emitter = require("antena/emitter/webworker")(size)

  • size :: number
  • emitter :: antena.Emitter

emitter = require("antena/emitter/mock")(receptor)

  • receptor :: antena.Receptor
  • emitter :: antena.Emitter

emitter.request(method, path, headers, body, callback)

  • emitter :: antena.Emitter
  • method :: string
  • path :: string
  • headers :: {string}
  • body :: string
  • callback(error, status, reason, headers, body)
    • error :: Error
    • status :: number
    • reason :: string
    • headers :: {string}
    • body :: string

[error2, status2, reason2, headers2, body2] = emitter.request(method1, path1, headers1, body1)

  • emitter :: antena.Emitter
  • method1 :: string
  • path1 :: string
  • headers1 :: {string}
  • body1 :: string
  • error2 :: Error
  • status2 :: number
  • reason2 :: string
  • headers2 :: {string}
  • body2 :: string

websocket = emitter.connect(path)

  • emitter :: antena.Emitter
  • path(string)
  • websocket :: antena.Websocket

emitters = emitter.split(splitters)

  • emitter :: antena.Emitter
  • splitter :: [string]
  • emitters :: {antena.Emitter}

emitter2 = emitter1.trace(name)

  • emitter1 :: antena.Emitter
  • name(string)
  • emitter2 :: antena.Emitter

Websocket

websocket.send(message)

  • websocket :: antena.Websocket
  • message :: string | ArrayBuffer | Blob | Buffer

websocket.close(code, reason)

  • websocket :: antena.Websocket
  • code(number)
  • reason(string)

Event: "open"

Event: "message"

  • message :: string | ArrayBuffer

Event: close

  • code :: number
  • reason :: string

About

Communication library for performing http(s) request and opening websockets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published