leaps: github.com/Jeffail/leaps/lib/api/io Index | Files

package io

import "github.com/Jeffail/leaps/lib/api/io"

Package io - Contains network api.Emitter implementations for io types.


Package Files

concurrent_json_read_writer.go json_emitter.go package.go

type ConcurrentJSON Uses

type ConcurrentJSON struct {
    C ReadWriteJSONCloser
    // contains filtered or unexported fields

ConcurrentJSON - Wraps a ReadWriteJSONCloser with mutexes that allow multiple concurrent readers/writers.

func (*ConcurrentJSON) Close Uses

func (c *ConcurrentJSON) Close() error

Close - Close the read/writer

func (*ConcurrentJSON) ReadJSON Uses

func (c *ConcurrentJSON) ReadJSON(v interface{}) error

ReadJSON - Safely read JSON.

func (*ConcurrentJSON) WriteJSON Uses

func (c *ConcurrentJSON) WriteJSON(v interface{}) error

WriteJSON - Safely write JSON.

type JSONEmitter Uses

type JSONEmitter struct {
    // contains filtered or unexported fields

JSONEmitter - Instantiated for each incoming connection, which implements the ReadWriteJSONCloser interface. JSONEmitter implements the leaps API by allowing components to register their own request and event handlers. All incoming messages are expected to be of the JSON format:

  "type": "<type_string>",
  "body": {...}

Handlers for request types are given the unparsed JSON body of the request.

func NewJSONEmitter Uses

func NewJSONEmitter(rw ReadWriteJSONCloser) *JSONEmitter

NewJSONEmitter - Constructs a new JSONEmitter around a ReadWriteJSONCloser.

func (*JSONEmitter) Close Uses

func (w *JSONEmitter) Close() error

Close - Close the underlying network connection.

func (*JSONEmitter) ListenAndEmit Uses

func (w *JSONEmitter) ListenAndEmit()

ListenAndEmit - Begins reading to the underlying io.ReadWriteJSONCloser and emitting events accordingly.

func (*JSONEmitter) OnClose Uses

func (w *JSONEmitter) OnClose(eventHandler api.EventHandler)

OnClose - Register an event handler for a close event.

func (*JSONEmitter) OnReceive Uses

func (w *JSONEmitter) OnReceive(reqType string, reqHandler api.RequestHandler)

OnReceive - Register a handler for a particular incoming event type.

func (*JSONEmitter) OnSend Uses

func (w *JSONEmitter) OnSend(resType string, resHandler api.ResponseHandler)

OnSend - Register a handler for a particular outgoing event type.

func (*JSONEmitter) Send Uses

func (w *JSONEmitter) Send(resType string, data interface{}) error

Send - Send data to the connected client.

type ReadWriteJSONCloser Uses

type ReadWriteJSONCloser interface {
    ReadJSON(v interface{}) error
    WriteJSON(v interface{}) error
    Close() error

ReadWriteJSONCloser - An interface for writing and reading JSON content.

Package io imports 4 packages (graph). Updated 2018-03-20. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).