Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface {
OnConnect(c *connection.Connection)
OnMessage(c *connection.Connection, buffer *ringbuffer.RingBuffer) []byte
OnClose(c *connection.Connection)
}
Handler Server 注册接口
type Options ¶
type Options struct {
Network string
Address string
NumLoops int
ReusePort bool
// contains filtered or unexported fields
}
Options 服务配置
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server gev Server
func (*Server) RunAfter ¶
func (s *Server) RunAfter(d time.Duration, f func()) *timingwheel.Timer
RunAfter 延时任务
Example ¶
handler := new(example)
s, err := NewServer(handler,
Network("tcp"),
Address(":1833"),
NumLoops(8),
ReusePort(true))
if err != nil {
panic(err)
}
go s.Start()
defer s.Stop()
s.RunAfter(time.Second, func() {
fmt.Println("RunAfter")
})
time.Sleep(2500 * time.Millisecond)
Output: RunAfter
func (*Server) RunEvery ¶
func (s *Server) RunEvery(d time.Duration, f func()) *timingwheel.Timer
RunEvery 定时任务
Example ¶
handler := new(example)
s, err := NewServer(handler,
Network("tcp"),
Address(":1833"),
NumLoops(8),
ReusePort(true))
if err != nil {
panic(err)
}
go s.Start()
defer s.Stop()
t := s.RunEvery(time.Second, func() {
fmt.Println("EveryFunc")
})
time.Sleep(4500 * time.Millisecond)
t.Stop()
time.Sleep(4500 * time.Millisecond)
Output: EveryFunc EveryFunc EveryFunc EveryFunc
Directories
¶
| Path | Synopsis |
|---|---|
|
benchmarks
|
|
|
client
command
|
|
|
evio-echo-server
command
|
|
|
eviop-echo-server
command
|
|
|
gnet-echo-server
command
|
|
|
net-echo-server
command
|
|
|
example
|
|
|
echo
command
|
|
|
maxconnection
command
|
|
|
pushmessage
command
|
|
Click to show internal directories.
Click to hide internal directories.





