本文整理汇总了Golang中github.com/zond/hackyhack/proc/interfaces.MCP类的典型用法代码示例。如果您正苦于以下问题:Golang MCP类的具体用法?Golang MCP怎么用?Golang MCP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MCP类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Subscribe
func Subscribe(m interfaces.MCP, sub *messages.Subscription) *messages.Error {
var merr *messages.Error
if err := m.Call(nil, m.GetResource(), messages.MethodSubscribe, []interface{}{sub}, &[]interface{}{&merr}); err != nil {
return err
}
return merr
}
开发者ID:zond,项目名称:hackyhack,代码行数:7,代码来源:util.go
示例2: EmitEvent
func EmitEvent(m interfaces.MCP, ev *messages.Event) *messages.Error {
var merr *messages.Error
if err := m.Call(nil, m.GetResource(), messages.MethodEmitEvent, []interface{}{ev}, &[]interface{}{&merr}); err != nil {
return err
}
return merr
}
开发者ID:zond,项目名称:hackyhack,代码行数:7,代码来源:util.go
示例3: GetLongDesc
func GetLongDesc(m interfaces.MCP, resource string) (string, *messages.Error) {
var desc string
var merr *messages.Error
if err := m.Call(LookAt, resource, messages.MethodGetLongDesc, nil, &[]interface{}{&desc, &merr}); err != nil {
return "", err
}
return desc, merr
}
开发者ID:zond,项目名称:hackyhack,代码行数:8,代码来源:util.go
示例4: GetContainer
func GetContainer(m interfaces.MCP, resource string) (string, *messages.Error) {
var container string
var merr *messages.Error
if err := m.Call(LookUp, resource, messages.MethodGetContainer, nil, &[]interface{}{&container, &merr}); err != nil {
return "", err
}
return container, merr
}
开发者ID:zond,项目名称:hackyhack,代码行数:8,代码来源:util.go
示例5: SendToClient
func SendToClient(m interfaces.MCP, msg string) {
var merr *messages.Error
if err := m.Call(nil, m.GetResource(), messages.MethodSendToClient, []string{msg}, &[]interface{}{&merr}); err != nil {
log.Fatal(err)
}
if merr != nil {
log.Fatal(merr)
}
}
开发者ID:zond,项目名称:hackyhack,代码行数:9,代码来源:util.go
示例6: GetShortDesc
func GetShortDesc(m interfaces.MCP, resource string) (*messages.ShortDesc, *messages.Error) {
desc, found := cache.get(resource)
if found {
return desc, nil
}
var merr *messages.Error
if err := m.Call(GlanceAt, resource, messages.MethodGetShortDesc, nil, &[]interface{}{&desc, &merr}); err != nil {
return nil, err
}
if merr != nil {
return nil, merr
}
cache.set(resource, desc)
return desc, nil
}
开发者ID:zond,项目名称:hackyhack,代码行数:15,代码来源:util.go
示例7: GetContent
func GetContent(m interfaces.MCP, resource string) ([]string, *messages.Error) {
container, err := GetContainer(m, m.GetResource())
if err != nil {
return nil, err
}
verb := LookInto
if resource == container {
verb = LookAround
}
var content []string
var merr *messages.Error
if err := m.Call(verb, resource, messages.MethodGetContent, nil, &[]interface{}{&content, &merr}); err != nil {
return nil, err
}
return content, merr
}
开发者ID:zond,项目名称:hackyhack,代码行数:16,代码来源:util.go
示例8: Identify
func Identify(m interfaces.MCP, what string) (mathes []string, err *messages.Error) {
what = strings.ToLower(what)
shortDescMap, err := GetShortDescMap(m, m.GetResource())
if err != nil {
return nil, err
}
// Exact match ("take rock")
matches := []string{}
for resource, desc := range shortDescMap {
if strings.HasPrefix(strings.ToLower(desc), what) {
matches = append(matches, resource)
}
}
// Number suffix ("take rock 2")
if len(matches) != 1 {
found, num, prefix := SplitEndNumber(what)
if found && num > 0 {
newMatches := []string{}
for resource, desc := range shortDescMap {
if strings.HasPrefix(strings.ToLower(desc), prefix) {
newMatches = append(newMatches, resource)
}
}
if len(newMatches) >= num {
matches = []string{newMatches[num-1]}
}
}
}
// Inside match ("take [large] rock")
if len(matches) == 0 {
newMatches := []string{}
for resource, desc := range shortDescMap {
parts := SplitWhitespace(desc)
for _, part := range parts {
if strings.HasPrefix(strings.ToLower(part), what) {
newMatches = append(newMatches, resource)
}
}
if len(newMatches) > 0 {
matches = newMatches
}
}
}
// Inside number suffix ("take [large] rock 2")
if len(matches) != 1 {
found, num, prefix := SplitEndNumber(what)
if found && num > 0 {
newMatches := []string{}
for resource, desc := range shortDescMap {
parts := SplitWhitespace(desc)
for _, part := range parts {
if strings.HasPrefix(strings.ToLower(part), prefix) {
newMatches = append(newMatches, resource)
}
}
if len(newMatches) >= num {
matches = []string{newMatches[num-1]}
}
}
}
}
return matches, nil
}
开发者ID:zond,项目名称:hackyhack,代码行数:69,代码来源:util.go
注:本文中的github.com/zond/hackyhack/proc/interfaces.MCP类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论