Documentation ¶
Index ¶
- Constants
- Variables
- func CompressNoContextTakeover(w io.WriteCloser, level int) io.ReadWriteCloser
- func ComputeAcceptKey(challengeKey string) string
- func DecompressNoContextTakeover(r io.Reader) io.ReadCloser
- func FormatCloseMessage(closeCode int, text string) []byte
- func GenerateChallengeKey() (string, error)
- type CloseError
- type Http2server
- type Http2stream
- type Httpserver
- func (hs *Httpserver) Ip(c gnet.Conn) (ip string)
- func (hs *Httpserver) IsMobile() bool
- func (hs *Httpserver) Lastvisit() int32
- func (hs *Httpserver) Out404(err error)
- func (hs *Httpserver) Output_data(bin []byte)
- func (hs *Httpserver) RandOut()
- func (hs *Httpserver) SetLastvisit(int32)
- func (hs *Httpserver) Static()
- func (hs *Httpserver) Upgradews(c gnet.Conn) (err error)
- func (hs *Httpserver) UserAgent() string
- type Request
- type Tlscodec
- type WSconn
Constants ¶
View Source
const ( // TextMessage denotes a text data message. The text message payload is // interpreted as UTF-8 encoded text data. TextMessage = 1 // BinaryMessage denotes a binary data message. BinaryMessage = 2 // CloseMessage denotes a close control message. The optional message // payload contains a numeric code and text. Use the FormatCloseMessage // function to format a close message payload. CloseMessage = 8 // PingMessage denotes a ping control message. The optional message payload // is UTF-8 encoded text. PingMessage = 9 // PongMessage denotes a ping control message. The optional message payload // is UTF-8 encoded text. PongMessage = 10 BinaryMessagefinalBit = BinaryMessage | finalBit )
The message types are defined in RFC 6455, section 11.8.
View Source
const ( CloseNormalClosure = 1000 CloseGoingAway = 1001 CloseProtocolError = 1002 CloseUnsupportedData = 1003 CloseNoStatusReceived = 1005 CloseAbnormalClosure = 1006 CloseInvalidFramePayloadData = 1007 ClosePolicyViolation = 1008 CloseMessageTooBig = 1009 CloseMandatoryExtension = 1010 CloseInternalServerErr = 1011 CloseServiceRestart = 1012 CloseTryAgainLater = 1013 CloseTLSHandshake = 1015 )
Close codes defined in RFC 6455, section 11.7.
Variables ¶
View Source
var ErrCloseSent = errors.New("websocket: close sent")
View Source
var ErrReadLimit = errors.New("websocket: read limit exceeded")
View Source
var Http2pool = sync.Pool{New: func() interface{} { hs := &Http2server{} hs.ReadPool, _ = ants.NewPool(http2MaxConcurrentStreams) hs.SendPool, _ = ants.NewPoolWithFunc(http2MaxConcurrentStreams, sendpool_static) hs.Streams = make([]*Http2stream, http2MaxConcurrentStreams) hs.Streams[0] = &Http2stream{sendch: make(chan int8), Out: &tls.MsgBuffer{}} hs.ReadMetaHeaders = hpack.NewDecoder(http2initialHeaderTableSize, nil) hs.Streams[0].svr = hs return hs }}
Functions ¶
func CompressNoContextTakeover ¶
func CompressNoContextTakeover(w io.WriteCloser, level int) io.ReadWriteCloser
func ComputeAcceptKey ¶
func DecompressNoContextTakeover ¶
func DecompressNoContextTakeover(r io.Reader) io.ReadCloser
func FormatCloseMessage ¶
FormatCloseMessage formats closeCode and text as a WebSocket close message.
func GenerateChallengeKey ¶
Types ¶
type CloseError ¶
type CloseError struct { // Code is defined in RFC 6455, section 11.7. Code int // Text is the optional text payload. Text string }
CloseError represents close frame.
func (*CloseError) Error ¶
func (e *CloseError) Error() string
type Http2server ¶
type Http2server struct { InHeader http2FrameHeader Setting struct { HEADER_TABLE_SIZE int //允许发送者以八位字节的形式通知远程端点用于解码头块的头压缩表的最大尺寸。编码器可以通过使用特定于头部块内头部压缩格式的信令来选择等于或小于此值的任何大小 ENABLE_PUSH bool //此设置可用于禁用服务器推送 SETTINGS_INITIAL_WINDOW_SIZE int32 //初始化默认的窗口大小 MAX_FRAME_SIZE int //指示发送者愿意接收的最大帧有效载荷的大小 MAX_HEADER_LIST_SIZE int //此通报设置以八位字节的形式通知对等方发送方准备接受的标题列表的最大大小 } WorkStream *Http2stream ReadPool *ants.Pool SendPool *ants.PoolWithFunc Streams []*Http2stream ReadMetaHeaders *hpack.Decoder // contains filtered or unexported fields }
func (*Http2server) Close ¶
func (h2s *Http2server) Close()
type Http2stream ¶
type Http2stream struct { Out *tls.MsgBuffer Headers []hpack.HeaderField In *tls.MsgBuffer Id uint32 IN_WINDOW_SIZE, OUT_WINDOW_SIZE int32 // contains filtered or unexported fields }
func (*Http2stream) Out404Frame ¶
func (stream *Http2stream) Out404Frame(err error)
func (*Http2stream) RandOut ¶ added in v1.1.6
func (stream *Http2stream) RandOut()
type Httpserver ¶
type Httpserver struct { Request Request Out *tls.MsgBuffer Ws *WSconn // contains filtered or unexported fields }
func (*Httpserver) IsMobile ¶
func (hs *Httpserver) IsMobile() bool
func (*Httpserver) Lastvisit ¶
func (hs *Httpserver) Lastvisit() int32
func (*Httpserver) Out404 ¶
func (hs *Httpserver) Out404(err error)
func (*Httpserver) Output_data ¶
func (hs *Httpserver) Output_data(bin []byte)
func (*Httpserver) RandOut ¶ added in v1.1.6
func (hs *Httpserver) RandOut()
func (*Httpserver) SetLastvisit ¶
func (hs *Httpserver) SetLastvisit(int32)
func (*Httpserver) Static ¶
func (hs *Httpserver) Static()
func (*Httpserver) Upgradews ¶
func (hs *Httpserver) Upgradews(c gnet.Conn) (err error)
http升级为websocket
func (*Httpserver) UserAgent ¶
func (hs *Httpserver) UserAgent() string
type Request ¶
type WSconn ¶
type WSconn struct { Http *Httpserver //以下是发送接收相关 IsCompress bool ReadFinal bool // true the current message has more frames. ReadLength int // Message size. IsServer bool Write func([]byte) error Ctx interface{} // contains filtered or unexported fields }
func (*WSconn) Output_data ¶
func (*WSconn) ReadMessage ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.