Skip to main content

Class: Messaging

Defined in: bee-js/src/modules/messaging.ts:41

Messaging protocols — PSS (Postal Service for Swarm) and GSOC. Method names keep their pss/gsoc prefixes to distinguish the two protocols within the namespace.

Accessed as bee.messaging.

Constructors​

Constructor​

new Messaging(context): Messaging

Defined in: bee-js/src/modules/messaging.ts:42

Parameters​

context​

BeeContext

Returns​

Messaging

Methods​

gsocMine()​

gsocMine(targetOverlay, identifier, proximity): PrivateKey

Defined in: bee-js/src/modules/messaging.ts:154

Mines the signer (a private key) to be used to send GSOC messages to the specific target overlay address.

Parameters​

targetOverlay​

string | Uint8Array<ArrayBufferLike> | PeerAddress

identifier​

string | Uint8Array<ArrayBufferLike> | Identifier

proximity​

number = 12

Returns​

PrivateKey


gsocSend()​

gsocSend(postageBatchId, signer, identifier, data, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/modules/messaging.ts:189

Sends a GSOC message with the specified signer and identifier.

Warning! Only full nodes can accept GSOC messages.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

signer​

string | Uint8Array<ArrayBufferLike> | PrivateKey

identifier​

string | Uint8Array<ArrayBufferLike> | Identifier

data​

string | Uint8Array<ArrayBufferLike>

options?​

ChunkUploadOptions

requestOptions?​

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns​

Promise<UploadResult>


gsocSubscribe()​

gsocSubscribe(address, identifier, handler, options?): GsocSubscription

Defined in: bee-js/src/modules/messaging.ts:217

Subscribes to GSOC messages for the specified owner (of the signer) and identifier.

Warning! Only full nodes can accept GSOC messages.

Parameters​

address​

string | Uint8Array<ArrayBufferLike> | EthAddress

identifier​

string | Uint8Array<ArrayBufferLike> | Identifier

handler​

GsocMessageHandler

options?​

GsocSubscribeOptions

SOC fields to receive and whether to cache the wrapped chunk; requires Bee 2.8.3 or later

Returns​

GsocSubscription


pssReceive()​

pssReceive(topic, timeoutMsec): Promise<Bytes>

Defined in: bee-js/src/modules/messaging.ts:114

Receives a single message using the Postal Service for Swarm.

Warning! Only full nodes can accept PSS messages.

Parameters​

topic​

Topic

Topic name

timeoutMsec​

number = 0

Timeout in milliseconds

Returns​

Promise<Bytes>


pssSend()​

pssSend(postageBatchId, topic, target, data, recipient?, requestOptions?): Promise<void>

Defined in: bee-js/src/modules/messaging.ts:56

Sends data to a recipient or target with the Postal Service for Swarm.

Warning! Only full nodes can accept PSS messages.

Parameters​

postageBatchId​

Postage BatchId that will be assigned to the sent message.

string | Uint8Array<ArrayBufferLike> | BatchId

topic​

Topic

Topic name

target​

string

Target message address prefix

data​

Message to send

string | Uint8Array<ArrayBufferLike>

recipient?​

Optional recipient public key

string | PublicKey

requestOptions?​

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns​

Promise<void>


pssSubscribe()​

pssSubscribe(topic, handler): PssSubscription

Defined in: bee-js/src/modules/messaging.ts:80

Subscribes to messages for the given topic with the Postal Service for Swarm.

Warning! Only full nodes can accept PSS messages.

Parameters​

topic​

Topic

Topic name

handler​

PssMessageHandler

Message handler interface

Returns​

PssSubscription

💬 Get Help