Documentation ¶
Index ¶
- func FreeMessage(msg *Message)
- func HttpServer(handler http.Handler) *http.Server
- func ResetMessage(m *Message)
- func SetRouteVars(r *http.Request, val interface{})
- func Vars(r *http.Request) map[string]string
- type BufferPacker
- func (p *BufferPacker) Pack(msgID uint64, msg interface{}) ([]byte, error)
- func (p *BufferPacker) Read(conn *TcpSession) ([]byte, error)
- func (p *BufferPacker) SetMsgLen(lenMsgLen int32, minMsgLen uint32, maxMsgLen uint32)
- func (p *BufferPacker) Unpack(data []byte) (*Message, error)
- func (p *BufferPacker) Write(conn *TcpSession, buff ...byte) error
- type ByteBuffer
- func (bf *ByteBuffer) Append(buff []byte)
- func (bf *ByteBuffer) AppendInt16(x int16)
- func (bf *ByteBuffer) AppendInt32(x int32)
- func (bf *ByteBuffer) AppendInt64(x int64)
- func (bf *ByteBuffer) EnsureWritableBytes(len int32)
- func (bf *ByteBuffer) Length() int32
- func (bf *ByteBuffer) NextBytes(len int32) []byte
- func (bf *ByteBuffer) ReadBuff() []byte
- func (bf *ByteBuffer) ReadInt16() int16
- func (bf *ByteBuffer) ReadInt32() int32
- func (bf *ByteBuffer) ReadInt64() int64
- func (bf *ByteBuffer) Reserve(len int32)
- func (bf *ByteBuffer) Reset()
- func (bf *ByteBuffer) Retrieve(len int32)
- func (bf *ByteBuffer) SetByteOrder(littleEndian bool)
- func (bf *ByteBuffer) Skip(len int32)
- func (bf *ByteBuffer) Swap(other *ByteBuffer)
- func (bf *ByteBuffer) Truncate(n int32)
- func (bf *ByteBuffer) WriteBuff() []byte
- func (bf *ByteBuffer) WriteBytes(n int32)
- type HttpRouter
- func (g *HttpRouter) GetPageView() int64
- func (g *HttpRouter) Handle(method, path string, h http.Handler)
- func (g *HttpRouter) HandleFunc(method, path string, h func(http.ResponseWriter, *http.Request))
- func (g *HttpRouter) HandleStaticFile(method, path, dir string)
- func (g *HttpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (g *HttpRouter) SetNotFoundHandler(h http.Handler)
- type IPacker
- type ISession
- type Message
- type NormalPacker
- type Packet
- type RpcServer
- type TCPKeepAliveListener
- type TcpClient
- type TcpServer
- type TcpSession
- func (c *TcpSession) AsyncSend(msgID uint64, msg interface{}) bool
- func (c *TcpSession) AsyncSendLastPacket(msgID uint64, msg interface{}) bool
- func (c *TcpSession) AsyncSendRowMsg(data []byte) bool
- func (c *TcpSession) Close()
- func (c *TcpSession) Connect()
- func (c *TcpSession) HandleRead()
- func (c *TcpSession) HandleWrite()
- func (c *TcpSession) IsClosed() bool
- func (c *TcpSession) IsShutdown() bool
- func (c *TcpSession) LastSignal(signal []byte) error
- func (c *TcpSession) LocalAddr() net.Addr
- func (c *TcpSession) OnClose()
- func (c *TcpSession) OnConnect()
- func (c *TcpSession) Read(b []byte) (int, error)
- func (c *TcpSession) RemoteAddr() net.Addr
- func (c *TcpSession) Reset()
- func (c *TcpSession) Signal(signal []byte) error
- func (c *TcpSession) Verified() bool
- func (c *TcpSession) Verify()
- func (c *TcpSession) Write(b []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FreeMessage ¶ added in v1.0.5
func FreeMessage(msg *Message)
FreeMessage puts a Message into the pool.
func SetRouteVars ¶ added in v1.0.6
Types ¶
type BufferPacker ¶ added in v1.0.4
type BufferPacker struct {
// contains filtered or unexported fields
}
func (*BufferPacker) Pack ¶ added in v1.0.4
func (p *BufferPacker) Pack(msgID uint64, msg interface{}) ([]byte, error)
func (*BufferPacker) Read ¶ added in v1.0.4
func (p *BufferPacker) Read(conn *TcpSession) ([]byte, error)
Read goroutine safe
func (*BufferPacker) SetMsgLen ¶ added in v1.0.4
func (p *BufferPacker) SetMsgLen(lenMsgLen int32, minMsgLen uint32, maxMsgLen uint32)
SetMsgLen It's dangerous to call the method on reading or writing
func (*BufferPacker) Unpack ¶ added in v1.0.4
func (p *BufferPacker) Unpack(data []byte) (*Message, error)
Unpack id + protobuf data
func (*BufferPacker) Write ¶ added in v1.0.4
func (p *BufferPacker) Write(conn *TcpSession, buff ...byte) error
goroutine safe
type ByteBuffer ¶ added in v1.0.4
type ByteBuffer struct {
// contains filtered or unexported fields
}
ByteBuffer 字节buff
func (*ByteBuffer) AppendInt16 ¶ added in v1.0.4
func (bf *ByteBuffer) AppendInt16(x int16)
AppendInt16 ...
func (*ByteBuffer) AppendInt32 ¶ added in v1.0.4
func (bf *ByteBuffer) AppendInt32(x int32)
AppendInt32 ...
func (*ByteBuffer) AppendInt64 ¶ added in v1.0.4
func (bf *ByteBuffer) AppendInt64(x int64)
AppendInt64 ...
func (*ByteBuffer) EnsureWritableBytes ¶ added in v1.0.4
func (bf *ByteBuffer) EnsureWritableBytes(len int32)
EnsureWritableBytes ...
func (*ByteBuffer) NextBytes ¶ added in v1.0.4
func (bf *ByteBuffer) NextBytes(len int32) []byte
NextBytes 读取N字节
func (*ByteBuffer) ReadInt16 ¶ added in v1.0.4
func (bf *ByteBuffer) ReadInt16() int16
ReadInt16 ...
func (*ByteBuffer) ReadInt32 ¶ added in v1.0.4
func (bf *ByteBuffer) ReadInt32() int32
ReadInt32 ...
func (*ByteBuffer) ReadInt64 ¶ added in v1.0.4
func (bf *ByteBuffer) ReadInt64() int64
ReadInt64 ...
func (*ByteBuffer) Retrieve ¶ added in v1.0.4
func (bf *ByteBuffer) Retrieve(len int32)
Retrieve ...
func (*ByteBuffer) SetByteOrder ¶ added in v1.0.4
func (bf *ByteBuffer) SetByteOrder(littleEndian bool)
SetByteOrder It's dangerous to call the method on reading or writing
func (*ByteBuffer) Skip ¶ added in v1.0.4
func (bf *ByteBuffer) Skip(len int32)
Skip advances the reading index of the buffer
func (*ByteBuffer) WriteBuff ¶ added in v1.0.4
func (bf *ByteBuffer) WriteBuff() []byte
WriteBuff ...
func (*ByteBuffer) WriteBytes ¶ added in v1.0.4
func (bf *ByteBuffer) WriteBytes(n int32)
WriteBytes 写入n字节
type HttpRouter ¶ added in v1.0.6
type HttpRouter struct {
// contains filtered or unexported fields
}
func NewHttpRouter ¶ added in v1.0.6
func NewHttpRouter() *HttpRouter
func (*HttpRouter) GetPageView ¶ added in v1.0.6
func (g *HttpRouter) GetPageView() int64
func (*HttpRouter) Handle ¶ added in v1.0.6
func (g *HttpRouter) Handle(method, path string, h http.Handler)
func (*HttpRouter) HandleFunc ¶ added in v1.0.6
func (g *HttpRouter) HandleFunc(method, path string, h func(http.ResponseWriter, *http.Request))
func (*HttpRouter) HandleStaticFile ¶ added in v1.0.6
func (g *HttpRouter) HandleStaticFile(method, path, dir string)
func (*HttpRouter) ServeHTTP ¶ added in v1.0.6
func (g *HttpRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*HttpRouter) SetNotFoundHandler ¶ added in v1.0.6
func (g *HttpRouter) SetNotFoundHandler(h http.Handler)
type ISession ¶ added in v1.0.9
type ISession interface { OnConnect() OnClose() OnMessage(*Message, *TcpSession) }
type Message ¶
func GetPooledMessage ¶ added in v1.0.5
func GetPooledMessage() *Message
GetPooledMessage gets a pooled Message.
type NormalPacker ¶
func (*NormalPacker) Pack ¶
func (p *NormalPacker) Pack(msgID uint16, msg interface{}) ([]byte, error)
func (*NormalPacker) Read ¶ added in v1.0.4
func (p *NormalPacker) Read(conn *TcpSession) ([]byte, error)
type Packet ¶ added in v1.0.4
type Packet struct { Msg *Message Conn *TcpSession }
type RpcServer ¶ added in v1.0.6
type RpcServer struct { Addr string // contains filtered or unexported fields }
type TCPKeepAliveListener ¶ added in v1.0.8
type TCPKeepAliveListener struct {
*net.TCPListener
}
type TcpClient ¶ added in v1.0.5
type TcpClient struct { *TcpSession Address string ChMsg chan *Message OnMessageCb func(message *Packet) OnCloseCallBack func() // contains filtered or unexported fields }
func (*TcpClient) OnMessage ¶ added in v1.0.5
func (c *TcpClient) OnMessage(data *Message, conn *TcpSession)
type TcpServer ¶ added in v1.0.9
type TcpServer struct { Addr string MaxConnNum int MessageHandler func(packet *Packet) // contains filtered or unexported fields }
func NewTcpServer ¶ added in v1.0.9
func (*TcpServer) OnMessage ¶ added in v1.0.9
func (s *TcpServer) OnMessage(message *Message, conn *TcpSession)
type TcpSession ¶ added in v1.0.5
type TcpSession struct { Conn net.Conn Impl ISession ConnID int64 // contains filtered or unexported fields }
func NewTcpSession ¶ added in v1.0.5
func (*TcpSession) AsyncSend ¶ added in v1.0.5
func (c *TcpSession) AsyncSend(msgID uint64, msg interface{}) bool
func (*TcpSession) AsyncSendLastPacket ¶ added in v1.0.5
func (c *TcpSession) AsyncSendLastPacket(msgID uint64, msg interface{}) bool
AsyncSendLastPacket 缓存在发送队列里等待发送goroutine取出 (发送最后一个消息 发送会关闭tcp连接 终止tcp goroutine)
func (*TcpSession) AsyncSendRowMsg ¶ added in v1.0.5
func (c *TcpSession) AsyncSendRowMsg(data []byte) bool
func (*TcpSession) Close ¶ added in v1.0.5
func (c *TcpSession) Close()
func (*TcpSession) Connect ¶ added in v1.0.5
func (c *TcpSession) Connect()
func (*TcpSession) HandleRead ¶ added in v1.0.5
func (c *TcpSession) HandleRead()
func (*TcpSession) HandleWrite ¶ added in v1.0.5
func (c *TcpSession) HandleWrite()
func (*TcpSession) IsClosed ¶ added in v1.0.5
func (c *TcpSession) IsClosed() bool
func (*TcpSession) IsShutdown ¶ added in v1.0.5
func (c *TcpSession) IsShutdown() bool
func (*TcpSession) LastSignal ¶ added in v1.0.5
func (c *TcpSession) LastSignal(signal []byte) error
func (*TcpSession) LocalAddr ¶ added in v1.0.5
func (c *TcpSession) LocalAddr() net.Addr
func (*TcpSession) OnClose ¶ added in v1.0.5
func (c *TcpSession) OnClose()
func (*TcpSession) RemoteAddr ¶ added in v1.0.5
func (c *TcpSession) RemoteAddr() net.Addr
func (*TcpSession) Reset ¶ added in v1.0.5
func (c *TcpSession) Reset()
func (*TcpSession) Signal ¶ added in v1.0.5
func (c *TcpSession) Signal(signal []byte) error
func (*TcpSession) Verified ¶ added in v1.0.5
func (c *TcpSession) Verified() bool
func (*TcpSession) Verify ¶ added in v1.0.5
func (c *TcpSession) Verify()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.