mcastrpc

package module
v0.0.0-...-5675e2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2017 License: MIT Imports: 10 Imported by: 0

README

Multicast JSON RPC Server

Description

Multicast JSON RPC server

Installation

go get github.com/MarinX/mcastrpc

Notes

  • Multicast cannot be used in any sort of cloud, or shared infrastructure environment
  • Tested only on Linux
  • Be sure to run client on other PC, because address on network cannot be same

Example

package main

import (
    "fmt"
    "github.com/MarinX/mcastrpc"
)

type Api struct {
}

type Result struct {
    Success bool
    Message string
}

func main() {

    srv := mcastrpc.NewServer()

    err := srv.Register(new(Api), "Api")
    if err != nil {
	    fmt.Println(err)
	    return
    }

    if err := srv.ListenAndServe("224.0.0.251", 1712); err != nil {
	    fmt.Println(err)
    }

}

func (t *Api) Say(r *string, w *Result) error {
    *w = Result{
	    Success: true,
	    Message: "Hello," + *r,
    }
    return nil
}

TODO

  • Create multicast client

License

This library is under the MIT License

Author

Marin Basic

Documentation

Overview

mcastrpc

Index

Constants

View Source
const (
	MAX_READ_BYTES         = 8042
	JSONRPC_V2             = "2.0"
	ERROR_INVALID_REQUEST  = -32600
	ERROR_INVALID_JSON     = -32700
	ERROR_METHOD_NOT_EXIST = -32601
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) ListenAndServe

func (t *Server) ListenAndServe(host string, port int) error

func (*Server) Register

func (t *Server) Register(receiver interface{}, name string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL