Documentation ¶
Index ¶
- Variables
- type Client
- type Config
- type Conn
- func (c *Conn) Addr() net.Addr
- func (c *Conn) Broadcast(chname, name string, args ...interface{}) error
- func (c *Conn) Close() error
- func (c *Conn) Emit(name string, args ...interface{}) (err error)
- func (c *Conn) Join(chname string)
- func (c *Conn) Leave(chname string)
- func (c *Conn) OnClose(handler func())
- func (c *Conn) OnError(handler func(error))
- type EventHandler
- type Message
- type MessageSender
- type MessageType
- type Server
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadArgLen = errors.New("invalid number of arguments") ErrBadDispatch = errors.New("type mismatch") ErrNoData = errors.New("no data") ErrNotFunc = errors.New("not a function") ErrNilFunc = errors.New("nil function") )
Common handler errors.
var (
ErrNotInChan = errors.New("not in channel")
)
Common handler errors.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { EventHandler // contains filtered or unexported fields }
Client holds an RPC client connection.
func (*Client) NextMessage ¶
NextMessage gets the next message.
type Conn ¶
type Conn struct { EventHandler // contains filtered or unexported fields }
Conn represents an RPC connection.
func (*Conn) Broadcast ¶
Broadcast sends an event to a channel. This function fails if the user is not in the channel and returns ErrNotInChan. Note that this method doesn't send the event back to the user who sent it; for that, use Server.Broadcast instead.
type EventHandler ¶
type EventHandler struct {
// contains filtered or unexported fields
}
EventHandler provides a basic event handling system.
func (*EventHandler) On ¶
func (c *EventHandler) On(name string, fn interface{})
On connects a function to an event handler.
type Message ¶
type Message struct { Type MessageType `json:"type"` Ack int `json:"ack,omitempty"` Name string `json:"name,omitempty"` Data []json.RawMessage `json:"data,omitempty"` }
Message represents a raw RPC message.
type MessageSender ¶
type MessageSender interface {
// contains filtered or unexported methods
}
MessageSender represents classes that can send Messages.
type MessageType ¶
type MessageType int
MessageType represents the kind of low-level message being received.
const ( Init MessageType = 0 Event MessageType = 1 Reply MessageType = 2 Ping MessageType = 3 Pong MessageType = 4 )
This is an enumeration of possible event types.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements an RPC server.
func NewServerWithConfig ¶
NewServerWithConfig creates a new server with config.