Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add send byte data test #14

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ func TestSendConnectWS(t *testing.T) {
sessions := session.ListSessions()
assert.Equal(t, 1, len(sessions))

//test send data
sessions[0].SendData([]byte("hello world"))
select {
case <-time.After(1 * time.Second):
t.Fatal("server get the data timeout")
case msg := <-testClient.datas:
assert.Equal(t, "hello world", string(msg))
}

uid = userLogin(t, "e2e")
assert.NotEmpty(t, uid)

Expand Down
4 changes: 4 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (sess *Session) SendMessage(in interface{}, name ...string) error {
return sess.agent.Send(in, name...)
}

func (sess *Session) SendData(data []byte) {
sess.agent.SendData(data)
}

func (sess *Session) GetLastTimeOnline() int64 {
return sess.agent.GetLastTimeOnline()
}
Expand Down