forked from YaoApp/yao
-
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.
v0.9.3 + socket server support ( yao start alpha )
- Loading branch information
Showing
11 changed files
with
100 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
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,29 @@ | ||
package server | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/yaoapp/gou" | ||
"github.com/yaoapp/xiang/config" | ||
"github.com/yaoapp/xiang/share" | ||
) | ||
|
||
// Load 加载API | ||
func Load(cfg config.Config) { | ||
var root = filepath.Join(cfg.RootAPI, "..", "servers") | ||
LoadFrom(root, "") | ||
} | ||
|
||
// LoadFrom 从特定目录加载 | ||
func LoadFrom(dir string, prefix string) { | ||
|
||
if share.DirNotExists(dir) { | ||
return | ||
} | ||
|
||
share.Walk(dir, ".sock.json", func(root, filename string) { | ||
name := prefix + share.SpecName(root, filename) | ||
content := share.ReadFile(filename) | ||
gou.LoadServer(string(content), name) | ||
}) | ||
} |
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,23 @@ | ||
package server | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/yaoapp/gou" | ||
"github.com/yaoapp/xiang/config" | ||
) | ||
|
||
func TestLoad(t *testing.T) { | ||
Load(config.Conf) | ||
LoadFrom("not a path", "404.") | ||
check(t) | ||
} | ||
|
||
func check(t *testing.T) { | ||
keys := []string{} | ||
for key := range gou.Servers { | ||
keys = append(keys, key) | ||
} | ||
assert.Equal(t, 1, len(keys)) | ||
} |
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,7 @@ | ||
{ | ||
"label": "读取RFID标签", | ||
"version": "1.0.0", | ||
"description": "读取RFID标签", | ||
"nodes": [{ "script": "print" }], | ||
"output": null | ||
} |
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,11 @@ | ||
function main(args, out, res) { | ||
// 100000012021128798321101 15 2d 02 f2 96 72 1e 52 b9 cd | ||
var idstr = args[0] || ""; | ||
var len = idstr.length; | ||
|
||
if (len != 36) { | ||
return; | ||
} | ||
id = BigInt("0x" + idstr.substring(8, len - 8).toUpperCase()).toString(10); | ||
console.log(id); | ||
} |
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,9 @@ | ||
{ | ||
"name": "RFID接收器", | ||
"description": "用来接收并处理RIFD", | ||
"version": "0.0.1", | ||
"protocol": "tcp", | ||
"host": "0.0.0.0", | ||
"port": "3019", | ||
"process": "flows.rfid.read" | ||
} |