Documentation
¶
Index ¶
Constants ¶
View Source
const Protocol = 4
Variables ¶
View Source
var ErrorInvalid = errors.New("invalid transport")
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
// Data is the ReadWriter of the attachment data.
Data io.ReadWriter
// contains filtered or unexported fields
}
Attachment is an attachment handler used in emit args. All attachments will send as binary in transport layer. When use attachment, make sure use as pointer.
For example:
type Arg struct {
Title string `json:"title"`
File *Attachment `json:"file"`
}
f, _ := os.Open("./some_file")
arg := Arg{
Title: "some_file",
File: &Attachment{
Data: f,
}
}
socket.Emit("send file", arg)
socket.On("get file", func(so Socket, arg Arg) {
b, _ := ioutil.ReadAll(arg.File.Data)
})
func (Attachment) MarshalJSON ¶
func (a Attachment) MarshalJSON() ([]byte, error)
func (*Attachment) UnmarshalJSON ¶
func (a *Attachment) UnmarshalJSON(b []byte) error
type MessageType ¶
type MessageType message.MessageType
const ( MessageBinary MessageType = MessageType(message.MessageBinary) MessageText MessageType = MessageType(message.MessageText) )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.