Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
b237c39d
Commit
b237c39d
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix bindings channels comments
parent
e70a6fa6
No related branches found
No related tags found
3 merge requests
!510
Release
,
!419
rewrote the health tracker to both consider if there are waiting rounds and...
,
!340
Project/channels
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/channels.go
+121
-115
121 additions, 115 deletions
bindings/channels.go
with
121 additions
and
115 deletions
bindings/channels.go
+
121
−
115
View file @
b237c39d
...
@@ -42,21 +42,21 @@ type channelManagerTracker struct {
...
@@ -42,21 +42,21 @@ type channelManagerTracker struct {
mux
sync
.
RWMutex
mux
sync
.
RWMutex
}
}
// make create a ChannelsManager from an [channels.Manager], assigns it a
// make create a ChannelsManager from an [channels.Manager], assigns it a
unique
//
unique
ID, and adds it to the channelManagerTracker.
// ID, and adds it to the channelManagerTracker.
func
(
cmt
*
channelManagerTracker
)
make
(
c
channels
.
Manager
)
*
ChannelsManager
{
func
(
cmt
*
channelManagerTracker
)
make
(
c
channels
.
Manager
)
*
ChannelsManager
{
cmt
.
mux
.
Lock
()
cmt
.
mux
.
Lock
()
defer
cmt
.
mux
.
Unlock
()
defer
cmt
.
mux
.
Unlock
()
id
:=
cmt
.
count
chID
:=
cmt
.
count
cmt
.
count
++
cmt
.
count
++
cmt
.
tracked
[
id
]
=
&
ChannelsManager
{
cmt
.
tracked
[
chID
]
=
&
ChannelsManager
{
api
:
c
,
api
:
c
,
id
:
id
,
id
:
chID
,
}
}
return
cmt
.
tracked
[
id
]
return
cmt
.
tracked
[
chID
]
}
}
// get an ChannelsManager from the channelManagerTracker given its ID.
// get an ChannelsManager from the channelManagerTracker given its ID.
...
@@ -98,12 +98,13 @@ func (cm *ChannelsManager) GetID() int {
...
@@ -98,12 +98,13 @@ func (cm *ChannelsManager) GetID() int {
}
}
// NewChannelsManager constructs a ChannelsManager.
// NewChannelsManager constructs a ChannelsManager.
//
fixme
:
t
his is a work in progress and should not be used
//
FIXME
:
T
his is a work in progress and should not be used
an event model is
//
an event model is
implemented in the style of the bindings layer's
// implemented in the style of the bindings layer's
AuthCallbacks. Remove this
//
AuthCallbacks. Remove this
note when that has been done.
// note when that has been done.
//
//
// Parameters:
// Parameters:
// - e2eID - The tracked e2e object ID. This can be retrieved using [E2e.GetID].
// - e2eID - The tracked e2e object ID. This can be retrieved using
// [E2e.GetID].
// - udID - The tracked UD object ID. This can be retrieved using
// - udID - The tracked UD object ID. This can be retrieved using
// [UserDiscovery.GetID].
// [UserDiscovery.GetID].
func
NewChannelsManager
(
e2eID
,
udID
int
)
(
*
ChannelsManager
,
error
)
{
func
NewChannelsManager
(
e2eID
,
udID
int
)
(
*
ChannelsManager
,
error
)
{
...
@@ -176,9 +177,10 @@ func (cm *ChannelsManager) JoinChannel(channelJson []byte) error {
...
@@ -176,9 +177,10 @@ func (cm *ChannelsManager) JoinChannel(channelJson []byte) error {
//
//
// Returns:
// Returns:
// - []byte - A JSON marshalled list of IDs.
// - []byte - A JSON marshalled list of IDs.
//
// JSON Example:
// JSON Example:
// {
// {
//
"
U4x/lrFkvxuXu59LtHLon1sUhPJSCcnZND6SugndnVID",
// U4x/lrFkvxuXu59LtHLon1sUhPJSCcnZND6SugndnVID",
// "15tNdkKbYXoMn58NO6VbDMDWFEyIhTWEGsvgcJsHWAgD"
// "15tNdkKbYXoMn58NO6VbDMDWFEyIhTWEGsvgcJsHWAgD"
// }
// }
func
(
cm
*
ChannelsManager
)
GetChannels
()
([]
byte
,
error
)
{
func
(
cm
*
ChannelsManager
)
GetChannels
()
([]
byte
,
error
)
{
...
@@ -218,8 +220,9 @@ func (cm *ChannelsManager) GetChannelId(channelJson []byte) ([]byte, error) {
...
@@ -218,8 +220,9 @@ func (cm *ChannelsManager) GetChannelId(channelJson []byte) ([]byte, error) {
// channel.
// channel.
//
//
// Parameters:
// Parameters:
// - []byte - A JSON marshalled channel ID ([id.ID]). This may be retrieved
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may be
// using ChannelsManager.GetChannelId.
// retrieved using ChannelsManager.GetChannelId.
//
// Returns:
// Returns:
// - []byte - A JSON marshalled ChannelDef.
// - []byte - A JSON marshalled ChannelDef.
func
(
cm
*
ChannelsManager
)
GetChannel
(
marshalledChanId
[]
byte
)
([]
byte
,
error
)
{
func
(
cm
*
ChannelsManager
)
GetChannel
(
marshalledChanId
[]
byte
)
([]
byte
,
error
)
{
...
@@ -248,8 +251,8 @@ func (cm *ChannelsManager) GetChannel(marshalledChanId []byte) ([]byte, error) {
...
@@ -248,8 +251,8 @@ func (cm *ChannelsManager) GetChannel(marshalledChanId []byte) ([]byte, error) {
// channel was not previously joined.
// channel was not previously joined.
//
//
// Parameters:
// Parameters:
// -
[]byte
- A JSON marshalled channel ID ([id.ID]). This may be
retrieved
// -
marshalledChanId
- A JSON marshalled channel ID ([id.ID]). This may be
// using ChannelsManager.GetChannelId.
//
retrieved
using ChannelsManager.GetChannelId.
func
(
cm
*
ChannelsManager
)
LeaveChannel
(
marshalledChanId
[]
byte
)
error
{
func
(
cm
*
ChannelsManager
)
LeaveChannel
(
marshalledChanId
[]
byte
)
error
{
// Unmarshal channel ID
// Unmarshal channel ID
channelId
,
err
:=
id
.
Unmarshal
(
marshalledChanId
)
channelId
,
err
:=
id
.
Unmarshal
(
marshalledChanId
)
...
@@ -265,8 +268,8 @@ func (cm *ChannelsManager) LeaveChannel(marshalledChanId []byte) error {
...
@@ -265,8 +268,8 @@ func (cm *ChannelsManager) LeaveChannel(marshalledChanId []byte) error {
// memory (~3 weeks) over the event model.
// memory (~3 weeks) over the event model.
//
//
// Parameters:
// Parameters:
// -
[]byte
- A JSON marshalled channel ID ([id.ID]). This may be
retrieved
// -
marshalledChanId
- A JSON marshalled channel ID ([id.ID]). This may be
// using ChannelsManager.GetChannelId.
//
retrieved
using ChannelsManager.GetChannelId.
func
(
cm
*
ChannelsManager
)
ReplayChannel
(
marshalledChanId
[]
byte
)
error
{
func
(
cm
*
ChannelsManager
)
ReplayChannel
(
marshalledChanId
[]
byte
)
error
{
// Unmarshal channel ID
// Unmarshal channel ID
...
@@ -299,28 +302,28 @@ type ChannelSendReport struct {
...
@@ -299,28 +302,28 @@ type ChannelSendReport struct {
}
}
// SendGeneric is used to send a raw message over a channel. In general, it
// SendGeneric is used to send a raw message over a channel. In general, it
// should be wrapped in a function
which
defines the wire protocol
// should be wrapped in a function
that
defines the wire protocol
. If the final
//
If the final
message, before being sent over the wire, is too long, this will
// message, before being sent over the wire, is too long, this will
return an
//
return an
error. Due to the underlying encoding using compression, it isn't
// error. Due to the underlying encoding using compression, it isn't
possible to
//
possible to
define the largest payload that can be sent, but
// define the largest payload that can be sent, but
it will always be possible
//
it will always be possible
to send a payload of 802 bytes at minimum
// to send a payload of 802 bytes at minimum
. The meaning of validUntil depends
//
Them meaning of validUntil depends
on the use case.
// on the use case.
//
//
// Parameters:
// Parameters:
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
be
//
be
retrieved using ChannelsManager.GetChannelId.
// retrieved using ChannelsManager.GetChannelId.
// - messageType - The message type of the message. This will be a valid
// - messageType - The message type of the message. This will be a valid
// [channels.MessageType].
// [channels.MessageType].
// - message - The contents of the message. This need not be of data type
// - message - The contents of the message. This need not be of data type
// string, as the message could be a specified format that the channel
// string, as the message could be a specified format that the channel
may
//
may
recognize.
// recognize.
// - leaseTimeMS - The lease of the message. This will be how long the message
// - leaseTimeMS - The lease of the message. This will be how long the message
// is valid until, in
MS
. As per the channels.Manager
// is valid until, in
milliseconds
. As per the channels.Manager
// documentation, this has different meanings depending on the use case.
// documentation, this has different meanings depending on the use case.
// These use cases may be generic enough that they will not be enumerated
// These use cases may be generic enough that they will not be enumerated
// here.
// here.
// - cmixParamsJSON - A JSON marshalled [xxdk.CMIXParams]. This may be
// - cmixParamsJSON - A JSON marshalled [xxdk.CMIXParams]. This may be
empty,
//
empty,
and GetDefaultCMixParams will be used internally.
// and GetDefaultCMixParams will be used internally.
//
//
// Returns:
// Returns:
// - []byte - A JSON marshalled ChannelSendReport.
// - []byte - A JSON marshalled ChannelSendReport.
...
@@ -329,7 +332,8 @@ func (cm *ChannelsManager) SendGeneric(marshalledChanId []byte,
...
@@ -329,7 +332,8 @@ func (cm *ChannelsManager) SendGeneric(marshalledChanId []byte,
cmixParamsJSON
[]
byte
)
([]
byte
,
error
)
{
cmixParamsJSON
[]
byte
)
([]
byte
,
error
)
{
// Unmarshal channel ID and parameters
// Unmarshal channel ID and parameters
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -346,28 +350,28 @@ func (cm *ChannelsManager) SendGeneric(marshalledChanId []byte,
...
@@ -346,28 +350,28 @@ func (cm *ChannelsManager) SendGeneric(marshalledChanId []byte,
return
constructChannelSendReport
(
chanMsgId
,
rndId
,
ephId
)
return
constructChannelSendReport
(
chanMsgId
,
rndId
,
ephId
)
}
}
// SendAdminGeneric is used to send a raw message over a channel encrypted
// SendAdminGeneric is used to send a raw message over a channel encrypted
with
//
with
admin keys, identifying it as sent by the admin. In general, it
// admin keys, identifying it as sent by the admin. In general, it
should be
//
should be
wrapped in a function
which
defines the wire protocol
// wrapped in a function
that
defines the wire protocol
. If the final message,
//
If the final message,
before being sent over the wire, is too long, this will
// before being sent over the wire, is too long, this will
return an error. The
//
return an error. The
message must be at most 510 bytes long.
// message must be at most 510 bytes long.
//
//
// Parameters:
// Parameters:
// - adminPrivateKey - The PEM-encoded admin
's
RSA private key.
// - adminPrivateKey - The PEM-encoded admin RSA private key.
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
be
//
be
retrieved using ChannelsManager.GetChannelId.
// retrieved using ChannelsManager.GetChannelId.
// - messageType - The message type of the message. This will be a valid
// - messageType - The message type of the message. This will be a valid
// [channels.MessageType].
// [channels.MessageType].
// - message - The contents of the message. The message should be at most 510
// - message - The contents of the message. The message should be at most 510
// bytes. This need not be of data type string, as the message could be a
// bytes. This need not be of data type string, as the message could be a
// specified format that the channel may recognize.
// specified format that the channel may recognize.
// - leaseTimeMS - The lease of the message. This will be how long the message
// - leaseTimeMS - The lease of the message. This will be how long the message
// is valid until, in
MS
. As per the channels.Manager
// is valid until, in
milliseconds
. As per the channels.Manager
// documentation, this has different meanings depending on the use case.
// documentation, this has different meanings depending on the use case.
// These use cases may be generic enough that they will not be enumerated
// These use cases may be generic enough that they will not be enumerated
// here.
// here.
// - cmixParamsJSON - A JSON marshalled [xxdk.CMIXParams]. This may be
// - cmixParamsJSON - A JSON marshalled [xxdk.CMIXParams]. This may be
empty,
//
empty,
and GetDefaultCMixParams will be used internally.
// and GetDefaultCMixParams will be used internally.
//
//
// Returns:
// Returns:
// - []byte - A JSON marshalled ChannelSendReport.
// - []byte - A JSON marshalled ChannelSendReport.
...
@@ -383,7 +387,8 @@ func (cm *ChannelsManager) SendAdminGeneric(adminPrivateKey,
...
@@ -383,7 +387,8 @@ func (cm *ChannelsManager) SendAdminGeneric(adminPrivateKey,
}
}
// Unmarshal channel ID and parameters
// Unmarshal channel ID and parameters
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -398,20 +403,21 @@ func (cm *ChannelsManager) SendAdminGeneric(adminPrivateKey,
...
@@ -398,20 +403,21 @@ func (cm *ChannelsManager) SendAdminGeneric(adminPrivateKey,
}
}
// SendMessage is used to send a formatted message over a channel.
// SendMessage is used to send a formatted message over a channel.
// Due to the underlying encoding using compression, it isn't
// Due to the underlying encoding using compression, it isn't possible to define
// possible to define the largest payload that can be sent, but
// the largest payload that can be sent, but it will always be possible to send
// it will always be possible to send a payload of 798 bytes at minimum
// a payload of 798 bytes at minimum.
//
// The message will auto delete validUntil after the round it is sent in,
// The message will auto delete validUntil after the round it is sent in,
// lasting forever if [channels.ValidForever] is used.
// lasting forever if [channels.ValidForever] is used.
//
//
// Parameters:
// Parameters:
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
be
//
be
retrieved using ChannelsManager.GetChannelId.
// retrieved using ChannelsManager.GetChannelId.
// - message - The contents of the message. The message should be at most 510
// - message - The contents of the message. The message should be at most 510
// bytes. This is expected to be Unicode, and thus a string data type is
// bytes. This is expected to be Unicode, and thus a string data type is
// expected
// expected
// - leaseTimeMS - The lease of the message. This will be how long the message
// - leaseTimeMS - The lease of the message. This will be how long the message
// is valid until, in
MS
. As per the channels.Manager
// is valid until, in
milliseconds
. As per the channels.Manager
// documentation, this has different meanings depending on the use case.
// documentation, this has different meanings depending on the use case.
// These use cases may be generic enough that they will not be enumerated
// These use cases may be generic enough that they will not be enumerated
// here.
// here.
...
@@ -424,7 +430,8 @@ func (cm *ChannelsManager) SendMessage(marshalledChanId []byte,
...
@@ -424,7 +430,8 @@ func (cm *ChannelsManager) SendMessage(marshalledChanId []byte,
message
string
,
leaseTimeMS
int64
,
cmixParamsJSON
[]
byte
)
([]
byte
,
error
)
{
message
string
,
leaseTimeMS
int64
,
cmixParamsJSON
[]
byte
)
([]
byte
,
error
)
{
// Unmarshal channel ID and parameters
// Unmarshal channel ID and parameters
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -441,32 +448,33 @@ func (cm *ChannelsManager) SendMessage(marshalledChanId []byte,
...
@@ -441,32 +448,33 @@ func (cm *ChannelsManager) SendMessage(marshalledChanId []byte,
}
}
// SendReply is used to send a formatted message over a channel.
// SendReply is used to send a formatted message over a channel.
// Due to the underlying encoding using compression, it isn't
// Due to the underlying encoding using compression, it isn't possible to define
// possible to define the largest payload that can be sent, but
// the largest payload that can be sent, but it will always be possible to send
// it will always be possible to send a payload of 766 bytes at minimum.
// a payload of 766 bytes at minimum.
// If the message ID the reply is sent to does not exist, the other side will
//
// post the message as a normal message and not a reply.
// If the message ID the reply is sent to does not exist, then the other side
// will post the message as a normal message and not a reply.
// The message will auto delete validUntil after the round it is sent in,
// The message will auto delete validUntil after the round it is sent in,
// lasting forever if ValidForever is used.
// lasting forever if ValidForever is used.
//
//
// Parameters:
// Parameters:
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
be
//
be
retrieved using ChannelsManager.GetChannelId.
// retrieved using ChannelsManager.GetChannelId.
// - message - The contents of the message. The message should be at most 510
// - message - The contents of the message. The message should be at most 510
// bytes. This is expected to be Unicode, and thus a string data type is
// bytes. This is expected to be Unicode, and thus a string data type is
// expected.
// expected.
// - messageToReactTo - The marshalled [channel.MessageID] of the message
// - messageToReactTo - The marshalled [channel.MessageID] of the message
you
//
you
wish to reply to. This may be found in the ChannelSendReport if
// wish to reply to. This may be found in the ChannelSendReport if
replying
//
replying
to your own. Alternatively, if reacting to another user's
// to your own. Alternatively, if reacting to another user's
message, you may
//
message, you may
retrieve it via the ChannelMessageReceptionCallback
// retrieve it via the ChannelMessageReceptionCallback
registered using
//
registered using
RegisterReceiveHandler.
// RegisterReceiveHandler.
// - leaseTimeMS - The lease of the message. This will be how long the message
// - leaseTimeMS - The lease of the message. This will be how long the message
// is valid until, in
MS
. As per the channels.Manager
// is valid until, in
milliseconds
. As per the channels.Manager
// documentation, this has different meanings depending on the use case.
// documentation, this has different meanings depending on the use case.
// These use cases may be generic enough that they will not be enumerated
// These use cases may be generic enough that they will not be enumerated
// here.
// here.
// - cmixParamsJSON - A JSON marshalled [xxdk.CMIXParams]. This may be
// - cmixParamsJSON - A JSON marshalled [xxdk.CMIXParams]. This may be
empty,
//
empty,
and GetDefaultCMixParams will be used internally.
// and GetDefaultCMixParams will be used internally.
//
//
// Returns:
// Returns:
// - []byte - A JSON marshalled ChannelSendReport
// - []byte - A JSON marshalled ChannelSendReport
...
@@ -475,7 +483,8 @@ func (cm *ChannelsManager) SendReply(marshalledChanId []byte,
...
@@ -475,7 +483,8 @@ func (cm *ChannelsManager) SendReply(marshalledChanId []byte,
cmixParamsJSON
[]
byte
)
([]
byte
,
error
)
{
cmixParamsJSON
[]
byte
)
([]
byte
,
error
)
{
// Unmarshal channel ID and parameters
// Unmarshal channel ID and parameters
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -501,31 +510,27 @@ func (cm *ChannelsManager) SendReply(marshalledChanId []byte,
...
@@ -501,31 +510,27 @@ func (cm *ChannelsManager) SendReply(marshalledChanId []byte,
// Users will drop the reaction if they do not recognize the reactTo message.
// Users will drop the reaction if they do not recognize the reactTo message.
//
//
// Parameters:
// Parameters:
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
// - marshalledChanId - A JSON marshalled channel ID ([id.ID]). This may
be
//
be
retrieved using ChannelsManager.GetChannelId.
// retrieved using ChannelsManager.GetChannelId.
// - reaction - The user's reaction. This should be a single emoji with no
// - reaction - The user's reaction. This should be a single emoji with no
// other characters. As such, a Unicode string is expected.
// other characters. As such, a Unicode string is expected.
// - messageToReactTo - The marshalled [channel.MessageID] of the message
// - messageToReactTo - The marshalled [channel.MessageID] of the message you
// you wish to reply to. This may be found in the ChannelSendReport if
// wish to reply to. This may be found in the ChannelSendReport if replying
// replying to your own. Alternatively, if reacting to another user's
// to your own. Alternatively, if reacting to another user's message, you may
// message, you may retrieve it via the ChannelMessageReceptionCallback
// retrieve it via the ChannelMessageReceptionCallback registered using
// registered using RegisterReceiveHandler.
// RegisterReceiveHandler.
// - leaseTimeMS - The lease of the message. This will be how long the message
// - cmixParamsJSON - A JSON marshalled [xxdk.CMIXParams]. This may be empty,
// is valid until, in MS. As per the channels.Manager
// and GetDefaultCMixParams will be used internally.
// documentation, this has different meanings depending on the use case.
// These use cases may be generic enough that they will not be enumerated
// here.
// - cmixParamsJSON - A JSON marshalled [xxdk.CMIXParams]. This may be
// empty, and GetDefaultCMixParams will be used internally.
//
//
// Returns:
// Returns:
// - []byte - A JSON marshalled ChannelSendReport
// - []byte - A JSON marshalled ChannelSendReport
.
func
(
cm
*
ChannelsManager
)
SendReaction
(
marshalledChanId
[]
byte
,
func
(
cm
*
ChannelsManager
)
SendReaction
(
marshalledChanId
[]
byte
,
reaction
string
,
messageToReactTo
[]
byte
,
reaction
string
,
messageToReactTo
[]
byte
,
cmixParamsJSON
[]
byte
)
([]
byte
,
error
)
{
cmixParamsJSON
[]
byte
)
([]
byte
,
error
)
{
// Unmarshal channel ID and parameters
// Unmarshal channel ID and parameters
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
chanId
,
params
,
err
:=
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -545,8 +550,8 @@ func (cm *ChannelsManager) SendReaction(marshalledChanId []byte,
...
@@ -545,8 +550,8 @@ func (cm *ChannelsManager) SendReaction(marshalledChanId []byte,
return
constructChannelSendReport
(
chanMsgId
,
rndId
,
ephId
)
return
constructChannelSendReport
(
chanMsgId
,
rndId
,
ephId
)
}
}
// parseChannelsParameters is a helper function for the Send functions.
// parseChannelsParameters is a helper function for the Send functions.
It
//
It
parses the channel ID and the passed in parameters into their respective
// parses the channel ID and the passed in parameters into their respective
// objects. These objects are passed into the API via the internal send
// objects. These objects are passed into the API via the internal send
// functions.
// functions.
func
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
[]
byte
)
(
func
parseChannelsParameters
(
marshalledChanId
,
cmixParamsJSON
[]
byte
)
(
...
@@ -582,15 +587,15 @@ func constructChannelSendReport(channelMessageId cryptoChannel.MessageID,
...
@@ -582,15 +587,15 @@ func constructChannelSendReport(channelMessageId cryptoChannel.MessageID,
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Channel Receiving Logic
&
Callback Registration
//
// Channel Receiving Logic
and
Callback Registration //
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// ReceivedChannelMessageReport is a report structure returned via the
// ReceivedChannelMessageReport is a report structure returned via the
// ChannelMessageReceptionCallback. This report gives the context
// ChannelMessageReceptionCallback. This report gives the context
for the
//
for the
channel the message was sent to and the message itself.
// channel the message was sent to and the message itself.
This is returned via
//
This is returned via
the callback as JSON marshalled bytes.
// the callback as JSON marshalled bytes.
//
//
// Example
JSON
:
//
JSON
Example:
// {
// {
// "ChannelId": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
// "ChannelId": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
// "MessageId": "3S6DiVjWH9mLmjy1oaam/3x45bJQzOW6u2KgeUn59wA=",
// "MessageId": "3S6DiVjWH9mLmjy1oaam/3x45bJQzOW6u2KgeUn59wA=",
...
@@ -613,8 +618,8 @@ type ReceivedChannelMessageReport struct {
...
@@ -613,8 +618,8 @@ type ReceivedChannelMessageReport struct {
RoundsList
RoundsList
}
}
// ChannelMessageReceptionCallback is the callback that returns the
// ChannelMessageReceptionCallback is the callback that returns the
context for
//
context for
a channel message via the Callback.
// a channel message via the Callback.
type
ChannelMessageReceptionCallback
interface
{
type
ChannelMessageReceptionCallback
interface
{
Callback
(
receivedChannelMessageReport
[]
byte
,
err
error
)
Callback
(
receivedChannelMessageReport
[]
byte
,
err
error
)
}
}
...
@@ -622,12 +627,13 @@ type ChannelMessageReceptionCallback interface {
...
@@ -622,12 +627,13 @@ type ChannelMessageReceptionCallback interface {
// RegisterReceiveHandler is used to register handlers for non-default message
// RegisterReceiveHandler is used to register handlers for non-default message
// types. They can be processed by modules. It is important that such modules
// types. They can be processed by modules. It is important that such modules
// sync up with the event model implementation.
// sync up with the event model implementation.
//
// There can only be one handler per [channels.MessageType], and this will
// There can only be one handler per [channels.MessageType], and this will
// return an error on any re-registration.
// return an error on any re-registration.
//
//
// Parameters:
// Parameters:
// - messageType - represents the [channels.MessageType] which will
// - messageType - represents the [channels.MessageType] which will
have a
//
have a
registered listener
// registered listener
.
// - listenerCb - the callback which will be executed when a channel message
// - listenerCb - the callback which will be executed when a channel message
// of messageType is received.
// of messageType is received.
func
(
cm
*
ChannelsManager
)
RegisterReceiveHandler
(
messageType
int
,
func
(
cm
*
ChannelsManager
)
RegisterReceiveHandler
(
messageType
int
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment