network

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StreamMutex sync.Mutex

StreamMutex 流互斥锁

Functions

func SendStream

func SendStream(ctx context.Context, h host.Host, protocol, genre string, receiver peer.ID, data []byte) (*streams.ResponseMessage, error)

SendStream 向指定的节点发送流消息 参数:

  • protocol: 协议
  • genre: 类型
  • receiver: 接收方ID
  • data: 发送的内容

返回:

  • *streams.ResponseMessage: 响应消息
  • error: 错误信息

func SendStreamWithExistingStream

func SendStreamWithExistingStream(stream network.Stream, data []byte) (*streams.ResponseMessage, error)

SendStreamWithExistingStream 使用已存在的流发送消息 参数:

  • stream: network.Stream 已经建立的流
  • data: []byte 要发送的数据

返回:

  • *streams.ResponseMessage: 响应消息
  • error: 错误信息

func SendStreamWithReader

func SendStreamWithReader(ctx context.Context, h host.Host, protocol, genre string, receiver peer.ID, reader io.Reader) (*streams.ResponseMessage, error)

SendStreamWithReader 使用流式读取器发送数据到指定节点 参数:

  • protocol: protocols.ID 协议ID
  • genre: string 消息类型
  • receiver: peer.ID 目标节点ID
  • reader: io.Reader 数据读取器

返回值:

  • *streams.ResponseMessage: 响应消息
  • error: 如果发送过程中发生错误,返回相应的错误信息

Types

This section is empty.

Jump to

Keyboard shortcuts

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