-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8182ea
commit 46c3bfa
Showing
5 changed files
with
76 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package publisher | ||
|
||
import ( | ||
"github.com/DownerCase/ecal-go/ecal/publisher" | ||
) | ||
|
||
type Publisher struct { | ||
publisher.Publisher | ||
} | ||
|
||
func New() (*Publisher, error) { | ||
pub, err := publisher.New() | ||
return &Publisher{*pub}, err | ||
} | ||
|
||
func (p *Publisher) Send(msg string) error { | ||
p.Messages <- []byte(msg) | ||
return nil | ||
} | ||
|
||
func (p *Publisher) Create(topic string) error { | ||
return p.Publisher.Create(topic, | ||
publisher.DataType{ | ||
Name: "std::string", | ||
Encoding: "base", | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package publisher | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestProtobufPublisher(t *testing.T) { | ||
pub, err := New() | ||
|
||
if err != nil { | ||
t.Error(err) | ||
} | ||
defer pub.Delete() | ||
|
||
if err := pub.Create("testing"); err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if pub.Messages == nil { | ||
t.Error("Message channel nil") | ||
} | ||
|
||
// TODO: Check datatype information | ||
if err := pub.Send("my message"); err != nil { | ||
t.Error("Failed to send message", err) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters