Documentation
¶
Index ¶
- Constants
- func TypeMessages() et.Json
- type Adapter
- type AdapterRedis
- type AdapterWS
- type Channel
- type Client
- func (c *Client) Close()
- func (c *Client) Connect() error
- func (c *Client) ConnectTo(path string) error
- func (c *Client) DirectMessage(msg Message)
- func (c *Client) From() et.Json
- func (c *Client) Listener()
- func (c *Client) Ping()
- func (c *Client) Publish(channel string, message interface{}) error
- func (c *Client) Queue(channel, queue string, reciveFn func(Message))
- func (c *Client) Reconnect()
- func (c *Client) ReconnectCallback()
- func (c *Client) SendMessage(clientId string, message interface{}) error
- func (c *Client) SetDirectMessageCallback(reciveFn func(Message))
- func (c *Client) SetFrom(name string) error
- func (c *Client) SetReconnectCallback(reciveFn func(c *Client))
- func (c *Client) Stack(channel string, reciveFn func(Message))
- func (c *Client) Subscribe(channel string, reciveFn func(Message))
- func (c *Client) Unsubscribe(channel string)
- type ClientConfig
- type Hub
- func (h *Hub) Close()
- func (h *Hub) Describe() et.Json
- func (h *Hub) DrainChannel(channel, queue string) error
- func (h *Hub) From() et.Json
- func (h *Hub) GetChanel(name string) *Channel
- func (h *Hub) GetChannels(name, queue string) et.Items
- func (h *Hub) GetClients(key string) et.Items
- func (h *Hub) HttpConnect(w http.ResponseWriter, r *http.Request)
- func (h *Hub) HttpDescribe(w http.ResponseWriter, r *http.Request)
- func (h *Hub) HttpGetPublications(w http.ResponseWriter, r *http.Request)
- func (h *Hub) HttpGetSubscribers(w http.ResponseWriter, r *http.Request)
- func (h *Hub) HttpLogin(w http.ResponseWriter, r *http.Request)
- func (h *Hub) IsRun() bool
- func (h *Hub) JoinTo(master et.Json) error
- func (h *Hub) Live()
- func (h *Hub) NewChannel(name string, duration time.Duration) *Channel
- func (h *Hub) NewQueue(name, queue string, duration time.Duration) *Queue
- func (h *Hub) Publish(channel, queue string, msg Message, ignored []string, from et.Json)
- func (h *Hub) QueueSubscribe(clientId string, channel, queue string) error
- func (h *Hub) SendMessage(clientId string, msg Message) error
- func (h *Hub) SetName(name string)
- func (h *Hub) Stack(clientId string, channel string) error
- func (h *Hub) Start()
- func (h *Hub) Subscribe(clientId string, channel string) error
- func (h *Hub) Unsubscribe(clientId string, channel, queue string) error
- type Message
- type Queue
- type Subscriber
- type TpMessage
- type WsMessage
Constants ¶
const ( MSG_CLIENT_CONNECT = "Client connected id:%s name:%s to Hub:%s" MSG_CLIENT_DISCONNECT = "Client disconnected %s name:%s to Hub:%s" MSG_CONNECT_SUCCESSFULLY = "Connected successfully" MSG_DISCONNECT_SUCCESSFULLY = "Disconnected successfully" ERR_SERVER_NOT_FOUND = "Server not found" ERR_CLIENT_NOT_FOUND = "Client not found" ERR_CLIENT_IS_CLOSED = "Client is closed" ERR_NOT_WS_SERVICE = "Not websocket service" ERR_NOT_DEFINE_CLIENTID = "Not define clientId" ERR_NOT_DEFINE_USERNAME = "Not define username" ERR_NOT_CONNECT_WS = "Not connect socket" ERR_CLIENT_DISCONNECTED = "Client disconnected" ERR_CHANNEL_NOT_FOUND = "Channel not found" ERR_CHANNEL_NOT_SUBSCRIBERS = "Channel not subscribers - %s" ERR_CHANNEL_EMPTY = "Channel is empty" ERR_QUEUE_EMPTY = "Queue is empty" ERR_PARAM_NOT_FOUND = "Param not found" ERR_CLIENT_ID_EMPTY = "Client id is empty" ERR_MESSAGE_UNFORMATTED = "Message unformatted" ERR_REDISADAPTER_NOT_FOUND = "Redis adapter not found" ERR_INVALID_ID = "Invalid id" ERR_INVALID_NAME = "Invalid name" ERR_ADAPTER_NOT_FOUND = "Adapter not found" ERR_NOT_SIGNATURE = "not signature" PARAMS_UPDATED = "Params updated" )
const ServiceName = "Websocket"
Variables ¶
This section is empty.
Functions ¶
func TypeMessages ¶
Types ¶
type Adapter ¶
type Adapter interface {
ConnectTo(hub *Hub, params et.Json) error
Close()
Subscribed(channel string)
UnSubscribed(channel string)
Publish(channel string, msg Message) error
}
func NewRedisAdapter ¶
func NewRedisAdapter() Adapter
func NewWSAdapter ¶
func NewWSAdapter() Adapter
type AdapterRedis ¶
type AdapterRedis struct {
// contains filtered or unexported fields
}
func (*AdapterRedis) ConnectTo ¶
func (s *AdapterRedis) ConnectTo(hub *Hub, params et.Json) error
* * ConnectTo * @param params et.Json * @return error *
func (*AdapterRedis) Publish ¶
func (s *AdapterRedis) Publish(channel string, msg Message) error
* * Publish * @param sub channel string *
func (*AdapterRedis) Subscribed ¶
func (s *AdapterRedis) Subscribed(channel string)
* * Subscribed * @param channel string *
func (*AdapterRedis) UnSubscribed ¶
func (s *AdapterRedis) UnSubscribed(channel string)
* * UnSubscribed * @param sub channel string *
type AdapterWS ¶
type AdapterWS struct {
// contains filtered or unexported fields
}
func (*AdapterWS) Subscribed ¶
* * Subscribed * @param channel string *
func (*AdapterWS) UnSubscribed ¶
* * UnSubscribed * @param sub channel string *
type Channel ¶
type Channel struct {
Name string `json:"name"`
Subscribers []*Subscriber `json:"subscribers"`
// contains filtered or unexported fields
}
* * Channel *
type Client ¶
type Client struct {
Channels map[string]func(Message)
Attempts *race.Value
Connected *race.Value
ClientId string
// contains filtered or unexported fields
}
func Login ¶
func Login(config *ClientConfig) (*Client, error)
* * NewNode * @config config ConectPatams * @return erro *
func NewClient ¶
func NewClient(config *ClientConfig) (*Client, error)
* * NewClient * @config config ConectPatams * @return erro *
func (*Client) DirectMessage ¶
* * DirectMessage * @param msg Message *
func (*Client) Publish ¶
* * Publish a message to a channel * @param channel string * @param message interface{} *
func (*Client) Queue ¶
* * Queue to a channel * @param channel, queue string * @param reciveFn func(message.Message) *
func (*Client) SendMessage ¶
* * SendMessage * @param clientId string * @param message interface{} * @return error *
func (*Client) SetDirectMessageCallback ¶
* * SetDirectMessageCallback * @param reciveFn func(message.Message) *
func (*Client) SetReconnectCallback ¶
* * SetReconnectCallback * @param reciveFn func() *
func (*Client) Stack ¶
* * Stack to a channel * @param channel string * @param reciveFn func(message.Message) *
func (*Client) Subscribe ¶
* * Subscribe to a channel * @param channel string * @param reciveFn func(message.Message) *
func (*Client) Unsubscribe ¶
* * Unsubscribe to a channel * @param channel string *
type ClientConfig ¶
type Hub ¶
func ServerHttp ¶
* * ServerHttp * @params port int * @params username string * @params password string * @return *Hub *
func (*Hub) DrainChannel ¶
* * DrainChannel * @param channel *Channel *
func (*Hub) GetChannels ¶
* * GetChannels of the hub * @param key string * @return et.Items *
func (*Hub) GetClients ¶
* * GetClients of the hub * @param key string * @return et.Items *
func (*Hub) HttpConnect ¶
func (h *Hub) HttpConnect(w http.ResponseWriter, r *http.Request)
* * HttpConnect connect to the server using the http * @param w http.ResponseWriter * @param r *http.Request *
func (*Hub) HttpDescribe ¶
func (h *Hub) HttpDescribe(w http.ResponseWriter, r *http.Request)
* * HttpGetPublications * @param w http.ResponseWriter * @param r *http.Request *
func (*Hub) HttpGetPublications ¶
func (h *Hub) HttpGetPublications(w http.ResponseWriter, r *http.Request)
* * HttpGetPublications * @param w http.ResponseWriter * @param r *http.Request *
func (*Hub) HttpGetSubscribers ¶
func (h *Hub) HttpGetSubscribers(w http.ResponseWriter, r *http.Request)
* * HttpGetSubscribers * @param w http.ResponseWriter * @param r *http.Request *
func (*Hub) HttpLogin ¶
func (h *Hub) HttpLogin(w http.ResponseWriter, r *http.Request)
* * HttpCluster connect to the server using the http * @param w http.ResponseWriter * @param r *http.Request *
func (*Hub) NewChannel ¶
* * NewChannel * @param name string * @param duration time.Duration * @return *Channel *
func (*Hub) NewQueue ¶
* * NewQueue * @param name string * @param duration time.Duration * @return *Queue *
func (*Hub) Publish ¶
* * Publish a message to a channel * @param channel string * @param msg Message * @param ignored []string * @param from et.Json * @return error *
func (*Hub) QueueSubscribe ¶
* * QueueSubscribe * @param clientId string * @param channel string * @param queue string * @return error *
func (*Hub) SendMessage ¶
* * SendMessage * @param clientId string * @param msg Message * @return error *
type Message ¶
type Message struct {
Created_at time.Time `json:"created_at"`
Id string `json:"id"`
From et.Json `json:"from"`
To string `json:"to"`
Ignored []string `json:"-"`
Data interface{} `json:"data"`
Channel string `json:"channel"`
Queue string `json:"queue"`
Type et.Json `json:"type"`
Tp TpMessage `json:"tp"`
}
func DecodeMessage ¶
* * DecodeMessage * @param []byte * @return Message *
func NewMessage ¶
* * NewMessage * @param et.Json * @param interface{} * @param TpMessage * @return Message *
type Queue ¶
type Queue struct {
Name string `json:"name"`
Queue string `json:"queue"`
Turn int `json:"turn"`
Subscribers []*Subscriber `json:"subscribers"`
// contains filtered or unexported fields
}