util

package
v0.0.0-...-d95647c Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SafeWebSocketDestroyError = fmt.Errorf("connection destroy by user")

Functions

func ComputeHmacMd5

func ComputeHmacMd5(strMessage, strSecret string) string

func ComputeHmacSha1

func ComputeHmacSha1(strMessage string, strSecret string) string

HMAC SHA1加密 strMessage: 需要加密的信息 strSecret: 密钥 return: BASE64编码的密文

func HexEncodeToString

func HexEncodeToString(input []byte) string

func HttpGetRequest

func HttpGetRequest(strUrl string, mapParams map[string]string) (string, error)

Http Get请求基础函数, 通过封装Go语言Http请求, 支持火币网REST API的HTTP Get请求 strUrl: 请求的URL strParams: string类型的请求参数, user=lxz&pwd=lxz return: 请求结果

func HttpPostRequest

func HttpPostRequest(strUrl string, mapParams, headerParams map[string]string) (string, error)

Http POST请求基础函数, 通过封装Go语言Http请求, 支持火币网REST API的HTTP POST请求 strUrl: 请求的URL mapParams: map类型的请求参数 return: 请求结果

func MD5

func MD5(input []byte) []byte

func Map2UrlQuery

func Map2UrlQuery(mapParams map[string]string) string

Map2UrlQuery : 将map格式的请求参数转换为字符串格式的 mapParams: map格式的参数键值对 return: 查询字符串

func MapSortByKey

func MapSortByKey(mapValue map[string]string) map[string]string

对Map按着ASCII码进行排序 mapValue: 需要进行排序的map return: 排序后的map

func MapValueEncodeURI

func MapValueEncodeURI(mapValue map[string]string) map[string]string

对Map的值进行URI编码 mapParams: 需要进行URI编码的map return: 编码后的map

Types

type SafeWebSocket

type SafeWebSocket struct {
	// contains filtered or unexported fields
}

SafeWebSocket 安全的WebSocket封装 保证读取和发送操作是并发安全的,支持自定义保持alive函数

func NewSafeWebSocket

func NewSafeWebSocket(endpoint string) (*SafeWebSocket, error)

NewSafeWebSocket 创建安全的WebSocket实例并连接

func (*SafeWebSocket) Destroy

func (s *SafeWebSocket) Destroy() (err error)

Destroy 销毁

func (*SafeWebSocket) KeepAlive

KeepAlive 设置alive周期及函数

func (*SafeWebSocket) Listen

Listen 监听消息

func (*SafeWebSocket) Loop

func (s *SafeWebSocket) Loop() error

Loop 进入事件循环,直到连接关闭才退出

func (*SafeWebSocket) Send

func (s *SafeWebSocket) Send(b []byte)

Send 发送消息

type SafeWebSocketAliveHandler

type SafeWebSocketAliveHandler = func()

type SafeWebSocketMessageListener

type SafeWebSocketMessageListener = func(b []byte)

Jump to

Keyboard shortcuts

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