update_version

package
v0.0.0-...-58a2b35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameError = 4005
)

Variables

View Source
var (
	Root_version_library                     = "version_library" //root节点版本文件存放根目录
	Version_dir                              = "versions"        //客户端新版本程序保持文件夹
	P2p_mgs_timeout                          = 5 * time.Second   //p2p消息超时时间为5s
	ErrNum                             int   = 5                 //传输失败重试次数 5次
	Lenth                              int64 = 2 * 1024 * 1024   //每次传输2M
	Update_version_expiration_interval       = 30 * time.Second  //定时检查更新间隔时间为30s
	TempFileSuffix                           = "_tmp"            //临时文件后缀名称
)

Functions

func CheckLatestVersion

func CheckLatestVersion(rj *model.RpcJson, w http.ResponseWriter, r *http.Request) (res []byte, err error)

func FindLatestVersionFileName

func FindLatestVersionFileName(src string) (string, error)

findLatestVersionFileName @Description: 查找最新版本文件名 @param src @return string @return error

func GetPlatform

func GetPlatform(rj *model.RpcJson, w http.ResponseWriter, r *http.Request) (res []byte, err error)

func GetRootNetAddr

func GetRootNetAddr(rj *model.RpcJson, w http.ResponseWriter, r *http.Request) (res []byte, err error)

func GetVersionFile

func GetVersionFile(rj *model.RpcJson, w http.ResponseWriter, r *http.Request) (res []byte, err error)

func LocalLatestVersion

func LocalLatestVersion(rj *model.RpcJson, w http.ResponseWriter, r *http.Request) (res []byte, err error)

func OriginVersionLibrary

func OriginVersionLibrary(rj *model.RpcJson, w http.ResponseWriter, r *http.Request) (res []byte, err error)

func RegisterRPC

func RegisterRPC()

func SetPlatform

func SetPlatform(rj *model.RpcJson, w http.ResponseWriter, r *http.Request) (res []byte, err error)

func SetRootNetAddr

func SetRootNetAddr(rj *model.RpcJson, w http.ResponseWriter, r *http.Request) (res []byte, err error)

func Start

func Start(uv *UpdateVersion)

Types

type NewVersionFileCallBack

type NewVersionFileCallBack func(newFilePath string)

新版本文件下载到本地成功后的回调方法 @newFilePath string 新版本文件全路径

type UpdateVersion

type UpdateVersion struct {
	RootNetAddr nodeStore.AddressNet `json:"to"` //接收者
	Platform    string

	Callback NewVersionFileCallBack //新版本文件更新成功的回调方法
	// contains filtered or unexported fields
}

func NewUpdateVersion

func NewUpdateVersion(area *libp2parea.Area, rootNetAddr nodeStore.AddressNet, platform string, find_last_version, find_last_version_recv, pull_version_file, pull_version_file_recv, origin_version_library, origin_version_library_recv uint64) *UpdateVersion

func (*UpdateVersion) CheckLatestVersion

func (this *UpdateVersion) CheckLatestVersion() (isLatest bool, latestFileName, versionName string, localIndex, remoteIndex int, err error)

CheckLatestVersion @Description: 检查最新版本 @receiver this @return isLatest 是否是最新 @return latestFileName 最新版本文件名 @return versionName 最新版本名称 @return localIndex int 本地最新版本编号 @return remoteIndex int 远程最新版本编号 @return err

func (*UpdateVersion) FileSlicePush

func (this *UpdateVersion) FileSlicePush(c engine.Controller, msg engine.Packet, message *message_center.Message)

分片推送

func (*UpdateVersion) FileSlicePush_recv

func (this *UpdateVersion) FileSlicePush_recv(c engine.Controller, msg engine.Packet, message *message_center.Message)

func (*UpdateVersion) GetPlatform

func (this *UpdateVersion) GetPlatform() string

func (*UpdateVersion) GetRootNetAddr

func (this *UpdateVersion) GetRootNetAddr() string

func (*UpdateVersion) GetVersionFile

func (this *UpdateVersion) GetVersionFile(fileName string) error

GetVersionFile @Description: 获取版本文件 @receiver this @param fileName @return error

func (*UpdateVersion) LocalLatestVersion

func (this *UpdateVersion) LocalLatestVersion() (fileName, code string, index int, err error)
	LocalLatestVersion
	@Description: 获取本地最近版本文件名
	@receiver this
	@return fileName 最新版本文件名
 	@return code 最新版本编号
	@return err

func (*UpdateVersion) OriginVersionLibrary

func (this *UpdateVersion) OriginVersionLibrary() ([]string, error)

OriginVersionLibrary @Description: 获取远端版本文件列表 @receiver this @return []string @return error

func (*UpdateVersion) RecvFindLastVersion

func (this *UpdateVersion) RecvFindLastVersion(c engine.Controller, msg engine.Packet, message *message_center.Message)

func (*UpdateVersion) RecvFindLastVersion_recv

func (this *UpdateVersion) RecvFindLastVersion_recv(c engine.Controller, msg engine.Packet, message *message_center.Message)

func (*UpdateVersion) RecvOriginVersionLibrary

func (this *UpdateVersion) RecvOriginVersionLibrary(c engine.Controller, msg engine.Packet, message *message_center.Message)

func (*UpdateVersion) RecvOriginVersionLibrary_recv

func (this *UpdateVersion) RecvOriginVersionLibrary_recv(c engine.Controller, msg engine.Packet, message *message_center.Message)

func (*UpdateVersion) SetCallback

func (this *UpdateVersion) SetCallback(callback NewVersionFileCallBack)

设置新版本文件下载到本地成功后的回调方法 @callback NewVersionFileCallBack 回调函数

func (*UpdateVersion) SetPlatform

func (this *UpdateVersion) SetPlatform(p string)

func (*UpdateVersion) SetRootNetAddr

func (this *UpdateVersion) SetRootNetAddr(addr string)

func (*UpdateVersion) TickerUpdateVersion

func (this *UpdateVersion) TickerUpdateVersion()

TickerUpdateVersion @Description: 定时检查并更新 @receiver this

type VersionFilePull

type VersionFilePull struct {
	Name  string `json:"name"` //原始文件名
	Size  int64  `json:"size"`
	Path  string `json:"path"`
	Index int64  `json:"index"`
	Data  []byte `json:"data"`
	Rate  int64  `json:"rate"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL