client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ChClosed channel closed
	ChClosed = "closed"
	// ChErrored channel errored
	ChErrored = "errored"
	// ChJoined channel joined
	ChJoined = "joined"
	// ChJoing channel joining
	ChJoing = "joining"

	// ChanClose channel close event
	ChanClose = "phx_close"
	// ChanError channel error event
	ChanError = "phx_error"
	// ChanReply server reply event
	ChanReply = "phx_reply"
	// ChanJoin  client send join event
	ChanJoin = "phx_join"
	// ChanLeave client send leave event
	ChanLeave = "phx_leave"
)
View Source
const (
	// ConnConnecting linter
	ConnConnecting = "connecting"
	// ConnOpen linter
	ConnOpen = "open"
	// ConnClosing linter
	ConnClosing = "closing"
	// Connclosed linter
	Connclosed = "closed"
)
View Source
const VSN = "1.0.0"

VSN linter

Variables

This section is empty.

Functions

This section is empty.

Types

type Chan

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

Chan channel

func (*Chan) GetRef

func (ch *Chan) GetRef() string

GetRef linter

func (*Chan) Join

func (ch *Chan) Join() (*Puller, error)

Join channel join, return a MsgCh to receive join result

func (*Chan) Leave

func (ch *Chan) Leave() (*Puller, error)

Leave channel leave, return a MsgCh to receive leave result

func (*Chan) OnEvent

func (ch *Chan) OnEvent(evt string) *Puller

OnEvent return a MsgCh to receive all msg on some event on this channel

func (*Chan) OnMessage

func (ch *Chan) OnMessage() *Puller

OnMessage register a MsgCh to recv all msg on channel

func (*Chan) Push

func (ch *Chan) Push(evt string, payload interface{}) error

Push send a msg to channel

func (*Chan) PushWithRef

func (ch *Chan) PushWithRef(ref, evt *string, payload interface{}) error

PushWithRef send a msg to channel

func (*Chan) Request

func (ch *Chan) Request(evt string, payload interface{}) (*Puller, error)

Request send a msg to channel and return a MsgCh to receive reply

type Connection

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

Connection handle phoenix connection

func Connect

func Connect(_url string, args url.Values) (*Connection, error)

Connect need to call first, auto reconnect if failed

func (*Connection) Chan

func (conn *Connection) Chan(topic string) (*Chan, error)

Chan create a new channel on connection

func (*Connection) Close

func (conn *Connection) Close()

Close linter

func (*Connection) OnMessage

func (conn *Connection) OnMessage() *Puller

OnMessage receive all message on connection

type Message

type Message struct {
	Topic   string      `json:"topic"`
	Event   string      `json:"event"`
	Ref     string      `json:"ref"`
	Payload interface{} `json:"payload"`
}

Message message

type Puller

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

Puller channel to receive result

func (*Puller) Close

func (puller *Puller) Close()

Close return puller to regCenter

func (*Puller) Pull

func (puller *Puller) Pull() <-chan *Message

Pull pull message from chan

type Socket

type Socket interface {
	Connect(_url string, args url.Values) error
	Send(*Message) error
	Recv() (*Message, error)
	Close() error
}

Socket interface for easy test

type WSocket

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

WSocket Socket implementation for web socket

func (*WSocket) Close

func (ws *WSocket) Close() error

Close implements Socket.Close

func (*WSocket) Connect

func (ws *WSocket) Connect(_url string, args url.Values) error

Connect linter

func (*WSocket) Recv

func (ws *WSocket) Recv() (*Message, error)

Recv implements Socket.Recv

func (*WSocket) Send

func (ws *WSocket) Send(msg *Message) error

Send implements Socket.Send

Jump to

Keyboard shortcuts

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