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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
b9013bef
Commit
b9013bef
authored
Apr 12, 2019
by
Bernardo Cardoso
Browse files
Options
Downloads
Patches
Plain Diff
Add some missing useful functions in API and bindings
parent
589f1b88
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/client.go
+4
-0
4 additions, 0 deletions
api/client.go
api/mockserver_test.go
+1
-1
1 addition, 1 deletion
api/mockserver_test.go
bindings/client.go
+8
-0
8 additions, 0 deletions
bindings/client.go
bindings/client_test.go
+3
-3
3 additions, 3 deletions
bindings/client_test.go
with
16 additions
and
4 deletions
api/client.go
+
4
−
0
View file @
b9013bef
...
@@ -222,6 +222,10 @@ func (cl *Client) GetSwitchboard() *switchboard.Switchboard {
...
@@ -222,6 +222,10 @@ func (cl *Client) GetSwitchboard() *switchboard.Switchboard {
return
cl
.
sess
.
GetSwitchboard
()
return
cl
.
sess
.
GetSwitchboard
()
}
}
func
(
cl
*
Client
)
GetCurrentUser
()
*
id
.
User
{
return
cl
.
sess
.
GetCurrentUser
()
.
User
}
// Logout closes the connection to the server at this time and does
// Logout closes the connection to the server at this time and does
// nothing with the user id. In the future this will release resources
// nothing with the user id. In the future this will release resources
// and safely release any sensitive memory.
// and safely release any sensitive memory.
...
...
This diff is collapsed.
Click to expand it.
api/mockserver_test.go
+
1
−
1
View file @
b9013bef
...
@@ -181,7 +181,7 @@ func TestSend(t *testing.T) {
...
@@ -181,7 +181,7 @@ func TestSend(t *testing.T) {
// Test send with valid inputs
// Test send with valid inputs
err
=
client
.
Send
(
APIMessage
{
SenderID
:
userID
,
Payload
:
[]
byte
(
"test"
),
err
=
client
.
Send
(
APIMessage
{
SenderID
:
userID
,
Payload
:
[]
byte
(
"test"
),
RecipientID
:
u
ser
ID
})
RecipientID
:
client
.
GetCurrentU
ser
()
})
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Error sending message: %v"
,
err
)
t
.
Errorf
(
"Error sending message: %v"
,
err
)
}
}
...
...
This diff is collapsed.
Click to expand it.
bindings/client.go
+
8
−
0
View file @
b9013bef
...
@@ -83,6 +83,14 @@ func (cl *Client) StopListening(listenerHandle string) {
...
@@ -83,6 +83,14 @@ func (cl *Client) StopListening(listenerHandle string) {
cl
.
client
.
StopListening
(
listenerHandle
)
cl
.
client
.
StopListening
(
listenerHandle
)
}
}
func
(
cl
*
Client
)
GetSwitchboard
()
*
switchboard
.
Switchboard
{
return
cl
.
client
.
GetSwitchboard
()
}
func
(
cl
*
Client
)
GetCurrentUser
()
*
id
.
User
{
return
cl
.
client
.
GetCurrentUser
()
}
func
FormatTextMessage
(
message
string
)
[]
byte
{
func
FormatTextMessage
(
message
string
)
[]
byte
{
return
api
.
FormatTextMessage
(
message
)
return
api
.
FormatTextMessage
(
message
)
}
}
...
...
This diff is collapsed.
Click to expand it.
bindings/client_test.go
+
3
−
3
View file @
b9013bef
...
@@ -212,13 +212,13 @@ func TestListen(t *testing.T) {
...
@@ -212,13 +212,13 @@ func TestListen(t *testing.T) {
client
.
Login
(
regRes
,
gwAddress
,
""
)
client
.
Login
(
regRes
,
gwAddress
,
""
)
listener
:=
MockListener
(
false
)
listener
:=
MockListener
(
false
)
client
.
Listen
(
id
.
ZeroID
[
:
],
int32
(
cmixproto
.
Type_NO_TYPE
),
&
listener
)
client
.
Listen
(
id
.
ZeroID
[
:
],
int32
(
cmixproto
.
Type_NO_TYPE
),
&
listener
)
client
.
client
.
GetSwitchboard
()
.
Speak
(
&
parse
.
Message
{
client
.
GetSwitchboard
()
.
Speak
(
&
parse
.
Message
{
TypedBody
:
parse
.
TypedBody
{
TypedBody
:
parse
.
TypedBody
{
MessageType
:
0
,
MessageType
:
0
,
Body
:
[]
byte
(
"stuff"
),
Body
:
[]
byte
(
"stuff"
),
},
},
Sender
:
id
.
ZeroID
,
Sender
:
id
.
ZeroID
,
Receiver
:
id
.
ZeroID
,
Receiver
:
client
.
GetCurrentUser
()
,
})
})
if
!
listener
{
if
!
listener
{
t
.
Error
(
"Message not received"
)
t
.
Error
(
"Message not received"
)
...
@@ -259,7 +259,7 @@ func TestStopListening(t *testing.T) {
...
@@ -259,7 +259,7 @@ func TestStopListening(t *testing.T) {
listener
:=
MockListener
(
false
)
listener
:=
MockListener
(
false
)
handle
:=
client
.
Listen
(
id
.
ZeroID
[
:
],
int32
(
cmixproto
.
Type_NO_TYPE
),
&
listener
)
handle
:=
client
.
Listen
(
id
.
ZeroID
[
:
],
int32
(
cmixproto
.
Type_NO_TYPE
),
&
listener
)
client
.
StopListening
(
handle
)
client
.
StopListening
(
handle
)
client
.
client
.
GetSwitchboard
()
.
Speak
(
&
parse
.
Message
{
client
.
GetSwitchboard
()
.
Speak
(
&
parse
.
Message
{
TypedBody
:
parse
.
TypedBody
{
TypedBody
:
parse
.
TypedBody
{
MessageType
:
0
,
MessageType
:
0
,
Body
:
[]
byte
(
"stuff"
),
Body
:
[]
byte
(
"stuff"
),
...
...
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