Documentation ¶
Overview ¶
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package websocket MIT License
# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func CodecForRequest(r *protocol.Request, name string) codec.Codec
- func DefaultErrorEncoder(ss *Session, r *protocol.Request, err error)
- func DefaultRequestDecoder(r *protocol.Request, v any) error
- func DefaultRequestEncoder(ctx context.Context, args any) ([]byte, error)
- func DefaultResponseDecoder(ctx context.Context, data []byte, out any) error
- func DefaultResponseEncoder(ss *Session, r *protocol.Request, reply *protocol.Reply, v any) error
- type AuthorizationHandler
- type CallOption
- type Client
- type ClientOption
- type ConnectedInterceptor
- type Context
- type DecodeResponseFunc
- type DecoderRequestFunc
- type DisconnectedInterceptor
- type EncoderErrorFunc
- type EncoderRequestFunc
- type EncoderResponseFunc
- type HandlerFunc
- type HandlersChain
- type Server
- type ServerConfig
- type ServerOption
- func AddMiddleware(selector string, mws ...middleware.Middleware) ServerOption
- func Address(address string) ServerOption
- func Authorization(handler AuthorizationHandler) ServerOption
- func Codec(codec codec.Codec) ServerOption
- func HandlerPoolSize(size int) ServerOption
- func Logger(logger *slog.Logger) ServerOption
- func Middleware(ms ...middleware.Middleware) ServerOption
- func Network(network string) ServerOption
- func OnConnected(onConnect ConnectedInterceptor) ServerOption
- func OnDisconnected(disconnect DisconnectedInterceptor) ServerOption
- func SessionPoolSize(size int) ServerOption
- func TLSConfig(config *tls.Config) ServerOption
- func Timeout(timeout time.Duration) ServerOption
- func Upgrader(upgrader websocket.FastHTTPUpgrader) ServerOption
- type Session
- type Transport
- type Transporter
- type UnimplementedOption
Constants ¶
const KindWebsocket transport.Kind = "websocket" // KindWebsocket websocket kind
Variables ¶
var ( // Name is name for transport Name transport.Kind = "websocket" )
Functions ¶
func CodecForRequest ¶
CodecForRequest get encoding.Codec via http.Request
func DefaultErrorEncoder ¶
DefaultErrorEncoder default error encoder
func DefaultRequestDecoder ¶
DefaultRequestDecoder default request decoder
func DefaultRequestEncoder ¶
DefaultRequestEncoder default request encoder
func DefaultResponseDecoder ¶
DefaultResponseDecoder default response decoder
Types ¶
type AuthorizationHandler ¶
AuthorizationHandler is a session authorization handler
type CallOption ¶
type CallOption interface {
// contains filtered or unexported methods
}
CallOption call options
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client ws client
type ClientOption ¶
type ClientOption func(c *Client)
ClientOption client option
func WithCodec ¶
func WithCodec(codec codec.Codec) ClientOption
WithCodec with client protocol codec
func WithEndpoint ¶
func WithEndpoint(endpoint string) ClientOption
WithEndpoint with client endpoint
func WithRequestEncoder ¶
func WithRequestEncoder(requestFunc EncoderRequestFunc) ClientOption
WithRequestEncoder with client request encoder.
func WithResponseDecoder ¶
func WithResponseDecoder(decode DecodeResponseFunc) ClientOption
WithResponseDecoder with client response decoder.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout with client timeout
type ConnectedInterceptor ¶
ConnectedInterceptor client connect interceptor
type DecodeResponseFunc ¶
DecodeResponseFunc is response decode func.
type DecoderRequestFunc ¶
DecoderRequestFunc is decoder request func.
type DisconnectedInterceptor ¶
type DisconnectedInterceptor func(ss *Session)
DisconnectedInterceptor client disconnect interceptor
type EncoderErrorFunc ¶
EncoderErrorFunc is encode error func.
type EncoderRequestFunc ¶
EncoderRequestFunc is request encode func.
type EncoderResponseFunc ¶
EncoderResponseFunc is encode response func.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is impl transport.Server
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
NewServer new a websocket server by options
func NewServerWithConfig ¶
func NewServerWithConfig(cs ...*ServerConfig) *Server
NewServerWithConfig create websocket with server config
func (*Server) Handler ¶
func (s *Server) Handler(operator string, handler HandlerFunc)
Handler 设置handler
func (*Server) Use ¶
func (s *Server) Use(selector string, m ...middleware.Middleware)
Use uses service middleware with selector.
type ServerConfig ¶
type ServerConfig struct { Network string `json:"network"` Address string `json:"address"` SessionPoolSize int `json:"session_pool_size"` HandlerPoolSize int `json:"handler_pool_size"` CertFile string `json:"cert_file"` KeyFile string `json:"key_file"` Timeout time.Duration `json:"timeout"` // contains filtered or unexported fields }
ServerConfig websocket server config
func DefaultServerConfig ¶
func DefaultServerConfig() *ServerConfig
DefaultServerConfig default server option
type ServerOption ¶
type ServerOption func(s *ServerConfig)
ServerOption is websocket server options
func AddMiddleware ¶
func AddMiddleware(selector string, mws ...middleware.Middleware) ServerOption
AddMiddleware add middlewares
func Authorization ¶
func Authorization(handler AuthorizationHandler) ServerOption
Authorization with an authorization option.
func HandlerPoolSize ¶
func HandlerPoolSize(size int) ServerOption
HandlerPoolSize with handler pool size
func Middleware ¶
func Middleware(ms ...middleware.Middleware) ServerOption
Middleware with middlewares
func OnConnected ¶
func OnConnected(onConnect ConnectedInterceptor) ServerOption
OnConnected with a connected callback option
func OnDisconnected ¶
func OnDisconnected(disconnect DisconnectedInterceptor) ServerOption
OnDisconnected with a disconnect callback option
func SessionPoolSize ¶
func SessionPoolSize(size int) ServerOption
SessionPoolSize with session pool size
func Upgrader ¶
func Upgrader(upgrader websocket.FastHTTPUpgrader) ServerOption
Upgrader with websocket.FastHTTPUpgrader option
type Session ¶
type Session struct { Id string `json:"id"` // contains filtered or unexported fields }
Session websocket client session
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is a websocket transport.
func (*Transport) ReplyHeader ¶
ReplyHeader returns the reply header.
func (*Transport) RequestHeader ¶
RequestHeader returns the request header.
type Transporter ¶
type Transporter interface { transport.Transporter }
Transporter is a websocket transport
type UnimplementedOption ¶
type UnimplementedOption struct { }
UnimplementedOption does not alter the Call configuration.