Documentation ¶
Index ¶
- Constants
- Variables
- func Connect(proto string, host string, port string, timeout time.Duration, bufferSize int, ...) error
- func Start(proto string, host string, port string, bufferSize int, KeepAlive int, ...)
- type Client
- type ClosedHandler
- type ConnectedHandler
- type DataHandler
- type ErrorHandler
- type Event
- type Handlers
- type Option
- type Socket
Constants ¶
View Source
const ( // WAITING waiting for connecting WAITING uint = iota // CONNECTING connecting the host CONNECTING // CONNECTED the socket is connected CONNECTED // CLOSED the socket is closed CLOSED )
View Source
const ( // MREAD socket read error ( the local peer closed ) MREAD uint = iota // MBREAK the remote peer closed MBREAK // MCLOSE user send the CLOSE signal MCLOSE )
Variables ¶
View Source
var Sockets = map[string]*Socket{}
Sockets sockets loaded (Alpha)
Functions ¶
Types ¶
type Client ¶
type Client struct { Status uint Conn net.Conn Option Option Handlers Handlers Attempts int AttemptAfter time.Duration AttemptTimes int }
Client the socket client
type Event ¶ added in v0.10.3
type Event struct { Data string `json:"data,omitempty"` Error string `json:"error,omitempty"` Closed string `json:"closed,omitempty"` Connected string `json:"connected,omitempty"` }
Event struct
type Handlers ¶
type Handlers struct { Data DataHandler Error ErrorHandler Closed ClosedHandler Connected ConnectedHandler }
Handlers the socket handlers
type Option ¶
type Option struct { Protocol string `json:"protocol,omitempty"` // TCP/UDP Host string `json:"host,omitempty"` Port string `json:"port,omitempty"` Timeout time.Duration `json:"timeout,omitempty"` // timeout (seconds) BufferSize int `json:"buffer,omitempty"` // bufferSize KeepAlive time.Duration `json:"keep,omitempty"` // -1 not keep alive, 0 keep alive always, keep alive n seconds. AttemptAfter time.Duration `json:"attempt_after,omitempty"` // Attempt attempt_after Attempts int `json:"attempts,omitempty"` // max times try to reconnect server when connection break (client mode only) }
Option the socket option
type Socket ¶ added in v0.10.3
type Socket struct { Name string `json:"name"` Version string `json:"version"` Mode string `json:"mode,omitempty"` // Server | client Description string `json:"description,omitempty"` Protocol string `json:"protocol,omitempty"` Host string `json:"host,omitempty"` Port string `json:"port,omitempty"` Event Event `json:"event,omitempty"` Timeout int `json:"timeout,omitempty"` // timeout (seconds) BufferSize int `json:"buffer,omitempty"` // bufferSize KeepAlive int `json:"keep,omitempty"` // -1 not keep alive, 0 keep alive always, keep alive n seconds. Process string `json:"process,omitempty"` AttemptAfter int `json:"attempt_after,omitempty"` // Attempt attempt_after Attempts int `json:"attempts,omitempty"` // max times try to reconnect server when connection break (client mode only) // contains filtered or unexported fields }
Socket struct
Click to show internal directories.
Click to hide internal directories.