Skip to content

Import path: gitlab.soludian.com/soludian/fountain/libs/fnet/fudp

fudp

go
import "gitlab.soludian.com/soludian/fountain/libs/fnet/fudp"

Index

Constants

go
const KMaxConcurrentConnection = 10000000

PackageName package name

go
const KPackageName = "ftcp_server"

Variables

go
var GetFountainInstance = Lib.GetFountainInstance

go
var GetFountainManager = Lib.GetFountainManager

Sử dụng khi config instance ở dạng key:value; Nếu config instance ở dạng key:array thì sử dụng hàm InstallFountainInstances Nếu config ở dạng key:array thì sẽ chỉ install config phần tử đầu tiên mà thôi

Install with config format <key>:<value>; eg: fudp:<value>

Usage:

config.yaml:

	fudp:
	  name: default_name
	  ...

	code.go

	fudp.InstallFountainInstance()

 fudp.WithConfigKey("fudp").InstallFountainInstance()
go
var InstallFountainInstance = Lib.InstallFountainInstance

Sử dụng khi config instance ở dạng key:array<value>; Sẽ luôn cố gắng khởi tạo kể cả khi config ở dạng key:value

Install with config format <key>:array<value>; eg: fudp:array<value>

Usage:

config.yaml:

fudp:
  - name: default_name
    ...

code.go

fudp.InstallFountainInstances()

fudp.WithConfigKey("fudp").InstallFountainInstances()
go
var InstallFountainInstances = Lib.InstallFountainInstances

go
var KDefaultServerName = env.GetFullAppService(KPackageName)

Truy cập thẳng tới bộ quản lý thư viện

go
var Lib = lib_3rd.NewLib(newServer, lib_3rd.WithDefaultConfigFunc[config, Server](DefaultConfig))

go
var WithConfigKey = Lib.WithConfigKey

func RegisterServiceHandler

go
func RegisterServiceHandler(x proto.Message, handler Handle)

RegisterServiceHandler func;

func WithAddr

go
func WithAddr(addr string) lib_3rd.Option[config]

func WithConfig

go
func WithConfig(conf *config) lib_3rd.Option[config]

func WithConnectionMaxIdleTime

go
func WithConnectionMaxIdleTime(duration time.Duration) lib_3rd.Option[config]

func WithMaxConcurrentConnection

go
func WithMaxConcurrentConnection(maxConcurrentConnection int) lib_3rd.Option[config]

func WithName

go
func WithName(name string) lib_3rd.Option[config]

func WithProtoName

go
func WithProtoName(protoName string) lib_3rd.Option[config]

func WithSendChanSize

go
func WithSendChanSize(sendChanSize int) lib_3rd.Option[config]

func WithServerCallbackInstance

go
func WithServerCallbackInstance(instance ServerCallback) lib_3rd.Option[config]

func WithVacuumInterval

go
func WithVacuumInterval(interval time.Duration) lib_3rd.Option[config]

type Handle

go
type Handle func(*net.UDPAddr, *codec.MessageController, proto.Message) error

func FindHandler

go
func FindHandler(msg proto.Message) Handle

FindHandler func;

type Server

go
type Server struct {
    *runnable.ServerInstance
    // contains filtered or unexported fields
}

func (*Server) Destroy

go
func (s *Server) Destroy() error

Destroy func

func (*Server) GetConnection

go
func (s *Server) GetConnection(addr *net.UDPAddr) *connect.Connection

GetConnection func

func (*Server) GetConnectionCount

go
func (s *Server) GetConnectionCount() int

GetConnection func

func (*Server) GracefulStop

go
func (s *Server) GracefulStop(ctx context.Context) error

GracefulStop implements Runnable interface it will stop echo server gracefully

func (*Server) IsRunning

go
func (s *Server) IsRunning() bool

IsRunning func

func (*Server) OnUDPConnectionClosed

go
func (s *Server) OnUDPConnectionClosed(conn *connect.Connection)

OnUDPConnectionClosed func to implement connect.ConnectionClosedCallback interface

func (*Server) PackageName

go
func (s *Server) PackageName() string

PackageName package name

func (*Server) Pause

go
func (s *Server) Pause()

Pause func

func (*Server) SendMessageBroadcast

go
func (s *Server) SendMessageBroadcast(msg any)

SendMessageBroadcast func; Send msg to all connection that was connected; msg can be either *codec.Message or proto.Message or []byte

func (*Server) SendMessageByConn

go
func (s *Server) SendMessageByConn(conn *connect.Connection, msg any) error

SendMessageByConn func; Find client by addr and send msg to all connection that was connected

func (*Server) SendMessageByConnAddr

go
func (s *Server) SendMessageByConnAddr(addr *net.UDPAddr, msg any) error

SendMessageByConnID func; Send data according to addr

func (*Server) SendMessageProtoByConn

go
func (s *Server) SendMessageProtoByConn(conn *connect.Connection, cntl *codec.MessageController, msg proto.Message) error

SendMessageProtoByConn func; Find client by addr and send msg to all connection that was connected

func (*Server) Serving

go
func (s *Server) Serving()

Serve func need run in a goroutine

type ServerCallback

go
type ServerCallback interface {
    OnUDPDataArrived(addr *net.UDPAddr, msg any) error
    OnUDPClientClosed(conn *connect.Connection)
}

Generated by gomarkdoc