Skip to content

Commit

Permalink
update echoServerAddr to codec server and echo sample (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjunbiao authored Nov 26, 2020
1 parent 9698d1f commit 9a9365b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func main() {
// automatically connect to the development server of yomo.run
// after successfully connected to the server, the plugin will receive the value
// of the key specified by the Observed() method every 2 seconds
yomo.RunDev(&EchoPlugin{}, "localhost:4241")
// yomo.RunDev(&EchoPlugin{}, "localhost:4241")
yomo.RunDevWith(&EchoPlugin{}, endpoint, yomo.OutputEchoData)
}

// EchoPlugin - a yomo plugin that converts received data into strings and appends
Expand All @@ -58,7 +59,7 @@ func (p *EchoPlugin) Handle(value interface{}) (interface{}, error) {
// Observed - returns a value of type string, which is the key monitored by echo plugin;
// the corresponding value will be passed into the Handle() method as an object
func (p EchoPlugin) Observed() string {
return "name"
return "0x11" //name
}

// Name - sets the name of a given plugin p (mainly used for debugging)
Expand All @@ -77,7 +78,7 @@ func (p EchoPlugin) Mold() interface{} {
1. Run `go run echo.go` from the terminal. If YoMo is installed successfully, you will see the following message:

```bash
% go run a.go
% go run echo.go
[EchoPlugin:6031]2020/07/06 22:14:20 plugin service start... [localhost:4241]
name:yomo!
name:yomo!
Expand Down
5 changes: 3 additions & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ func main() {

// 开发调试时运行该方法,处于联网状态时,程序会自动连接至 yomo.run 的开发服务器,连接成功后,
// 该Plugin会每2秒收到一条Observed()方法指定的Key的Value
yomo.RunDev(&EchoPlugin{}, "localhost:4241")
// yomo.RunDev(&EchoPlugin{}, "localhost:4241")
yomo.RunDevWith(&EchoPlugin{}, endpoint, yomo.OutputEchoData)
}

// EchoPlugin 是一个YoMo Plugin,会将接受到的数据转换成String形式,并再结尾添加内容,修改
Expand All @@ -185,7 +186,7 @@ func (p *EchoPlugin) Handle(value interface{}) (interface{}, error) {
// Observed 返回一个string类型的值,该值是EchoPlugin插件关注的数据流中的Key,该数据流中Key对应
// 的Value将会以对象的形式被传递进Handle()方法中
func (p EchoPlugin) Observed() string {
return "name"
return "0x11" //name
}

// Name 用于设置该Plugin的名称,方便Debug等操作
Expand Down
2 changes: 1 addition & 1 deletion configs/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ const (

func GetEchoConf() EchoConf {
conf := EchoConf{}
conf.EchoServerAddr = env.GetString(echoServerAddr, "161.189.140.133:11520")
conf.EchoServerAddr = env.GetString(echoServerAddr, "161.189.140.133:11521")
return conf
}

0 comments on commit 9a9365b

Please sign in to comment.