client

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 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"
)

Variables

This section is empty.

Functions

func ConnectWss

func ConnectWss(_url string, args url.Values) (*websocket.Conn, error)

ConnectWss linter

func GetElixirURL

func GetElixirURL(_url string, args url.Values) (string, error)

GetElixirURL linter

Types

type Chan

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

Chan linter

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 Client

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

Client linter

func (*Client) Chan

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

Chan linter

func (*Client) Close

func (conn *Client) Close() error

Close linter

func (*Client) MakeRef

func (conn *Client) MakeRef() string

MakeRef linter

func (*Client) OnMessage

func (conn *Client) OnMessage() *Puller

OnMessage receive all message on connection

func (*Client) Push

func (conn *Client) Push(msg *Message) error

Push linter

func (*Client) Register

func (conn *Client) Register(key string) *Puller

Register linter

func (*Client) Start

func (conn *Client) Start()

Start linter

type Connection

type Connection interface {
	Chan(topic string) (*Chan, error) //  Chan create a new channel on connection
	Push(msg *Message) error
	OnMessage() *Puller
	Close() error
	Start()
}

Connection linter

func Connect

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

Connect linter

type Message

type Message struct {
	Topic   string      `mapstructure:"topic" json:"topic"`
	Event   string      `mapstructure:"event" json:"event"`
	Ref     string      `mapstructure:"ref" json:"ref"`
	Payload interface{} `mapstructure:"payload" 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

func (*Puller) Push

func (puller *Puller) Push(msg *Message) bool

Push linter

type RegCenter

type RegCenter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RegCenter linter

func (*RegCenter) CloseAllPullers

func (center *RegCenter) CloseAllPullers()

CloseAllPullers linter

func (*RegCenter) GetPullers

func (center *RegCenter) GetPullers(key string) []*Puller

GetPullers linter

func (*RegCenter) Register

func (center *RegCenter) Register(key string) *Puller

Register linter

func (*RegCenter) Unregister

func (center *RegCenter) Unregister(puller *Puller)

Unregister linter

type RegisterCenter

type RegisterCenter interface {
	Register(key string) *Puller
	Unregister(puller *Puller)
	CloseAllPullers()
	GetPullers(key string) []*Puller
}

RegisterCenter regis and unregis puller

type Socket

type Socket interface {
	Send(*Message) error
	Recv() (*Message, error)
	Close() error
}

Socket linter

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) 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

type Wss

type Wss interface {
	Push(msg *Message) error
	Register(key string) *Puller
	MakeRef() string
}

Wss linter

Jump to

Keyboard shortcuts

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