rpc

package
v0.0.0-...-3339666 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2013 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEND_MESSAGE_PATH      = "/send.json"
	FORWARD_MESSAGE_PATH   = "/fwd.json"
	REDIRECT_CLIENT_PATH   = "/redir.json"
	USER_STATUS_QUERY_PATH = "/user-status.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnResult

type ConnResult struct {
	Address  string `json:"address"`
	ConnId   string `json:"conn-id"`
	Error    string `json:"error,omitempty"`
	Visible  bool   `json:"visible"`
	Username string `josn:"username"`
	Service  string `json:"service"`
}

type ForwardRequest

type ForwardRequest struct {
	NeverDigest   bool `json:"never-digest,omitempty"`
	DontPropagate bool `json:"dont-propagate,omitempty"`
	DontPush      bool `json:"dont-push,omitempty"`
	DontCache     bool `json:"dont-cache,omitempty"`

	DontAsk bool `json:"dont-ask-permission,omitempty"`

	Receivers       []string      `json:"receivers"`
	ReceiverService string        `json:"receiver-service"`
	TTL             time.Duration `json:"ttl"`
	MessageContainer
}

type Message

type Message struct {
	Header map[string]string `json:"header,omitempty"`
	Body   []byte            `json:"body,omitempty"`
}

func (*Message) Eq

func (a *Message) Eq(b *Message) bool

func (*Message) IsEmpty

func (self *Message) IsEmpty() bool

func (*Message) Size

func (self *Message) Size() int

type MessageContainer

type MessageContainer struct {
	Message       *Message  `json:"msg"`
	Id            string    `json:"id,omitempty"`
	Sender        string    `json:"s,omitempty"`
	SenderService string    `json:"ss,omitempty"`
	Birthday      time.Time `json:"b,omitempty"`
}

MessageContainer is used to represent a message inside the program. It has meta-data about a message like: the message id, the sender and the service of the sender.

func (*MessageContainer) Eq

func (*MessageContainer) FromServer

func (self *MessageContainer) FromServer() bool

func (*MessageContainer) FromUser

func (self *MessageContainer) FromUser() bool

type MultiPeer

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

func NewMultiPeer

func NewMultiPeer(peers ...UniqushConnPeer) *MultiPeer

func (*MultiPeer) AddPeer

func (self *MultiPeer) AddPeer(p UniqushConnPeer)

func (*MultiPeer) CheckUserStatus

func (self *MultiPeer) CheckUserStatus(req *UserStatusQuery) *Result

func (*MultiPeer) Forward

func (self *MultiPeer) Forward(req *ForwardRequest) *Result

func (*MultiPeer) Id

func (self *MultiPeer) Id() string

func (*MultiPeer) Redirect

func (self *MultiPeer) Redirect(req *RedirectRequest) *Result

func (*MultiPeer) Send

func (self *MultiPeer) Send(req *SendRequest) *Result

type RedirectRequest

type RedirectRequest struct {
	DontPropagate    bool     `json:"dont-propagate,omitempty`
	Receiver         string   `json:"receivers"`
	ReceiverService  string   `json:"receiver-service"`
	ConnId           string   `json:"conn-id"`
	CandidateSersers []string `json:"candidate-servers"`
}

type Result

type Result struct {
	Error   string        `json:"error,omitempty"`
	Results []*ConnResult `json:"results,omitempty"`
}

func (*Result) Append

func (self *Result) Append(c connDescriptor, err error)

func (*Result) Join

func (self *Result) Join(r *Result)

func (*Result) NrResults

func (self *Result) NrResults() int

func (*Result) NrSuccess

func (self *Result) NrSuccess() int

func (*Result) NrSuccessForUser

func (self *Result) NrSuccessForUser(service, user string) int

func (*Result) SetError

func (self *Result) SetError(err error)

type SendRequest

type SendRequest struct {
	NeverDigest   bool `json:"never-digest,omitempty"`
	DontPropagate bool `json:"dont-propagate,omitempty"`
	DontCache     bool `json:"dont-cache,omitempty"`
	DontPush      bool `json:"dont-push,omitempty"`

	Receivers       []string      `json:"receivers"`
	ReceiverService string        `json:"receiver-service"`
	TTL             time.Duration `json:"ttl"`
	Id              string        `json:"id,omitempty"`

	PushInfo map[string]string `json:"extra-push-info,omitempty"`
	Message  *Message          `json:"msg"`
}

type SubscribeRequest

type SubscribeRequest struct {
	Subscribe bool // false: unsubscribe; true: subscribe
	Service   string
	Username  string
	Params    map[string]string
}

type UniqushConnInstance

type UniqushConnInstance struct {
	Addr    string        `json:"addr"`
	Timeout time.Duration `json:"timeout,omitempty"`
}

func NewUniqushConnInstance

func NewUniqushConnInstance(u *url.URL, timeout time.Duration) (instance *UniqushConnInstance, err error)

func (*UniqushConnInstance) CheckUserStatus

func (self *UniqushConnInstance) CheckUserStatus(req *UserStatusQuery) *Result

func (*UniqushConnInstance) Forward

func (self *UniqushConnInstance) Forward(req *ForwardRequest) *Result

func (*UniqushConnInstance) Id

func (self *UniqushConnInstance) Id() string

func (*UniqushConnInstance) Redirect

func (self *UniqushConnInstance) Redirect(req *RedirectRequest) *Result

func (*UniqushConnInstance) Send

func (self *UniqushConnInstance) Send(req *SendRequest) *Result

type UniqushConnPeer

type UniqushConnPeer interface {
	Send(req *SendRequest) *Result
	Forward(req *ForwardRequest) *Result
	Redirect(req *RedirectRequest) *Result
	CheckUserStatus(req *UserStatusQuery) *Result
	Id() string
}

type UserStatusQuery

type UserStatusQuery struct {
	DontPropagate bool   `json:"dont-propagate,omitempty"`
	Service       string `json:"service"`
	Username      string `json:"username"`
}

Jump to

Keyboard shortcuts

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