我在我的应用程序中使用 pyAMF,但我想设置智能服务,如下所述:
在正常的应用程序中,我设置服务
services = {
'users.login': login,
'test': router
}
,但我想这样做:
services = [
'users.login',
'test'
]
每个请求都转到路由器功能。这需要 2 个参数:服务名称(在本例中可以是“users.login”或“test”)和输入(即由 flex 发送到 python 的对象) 那么如果来自flex的命令(服务)被命名为“users.login”。我想使用参数运行路由器,然后这将打开commands.users.login 包中的功能登录。我该怎么做呢?谢谢。
In a normal application i set services
services = {
'users.login': login,
'test': router
}
but I would like to do like this:
services = [
'users.login',
'test'
]
and every request goes to router function. this takes 2 params: service name (can be "users.login" or "test" in this case) and input (that is the object sent by flex to python)
then if the command(service) from flex is named "users.login". I would like to run the router with the params and then this will open the function login in the commands.users.login package. How would I do that? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确理解你的问题,为了实现这一点,你将需要重写你正在使用的网关类上的
getServiceRequest
:self.router
是一个您提供给网关构造函数的函数。它获取 AMF 远程处理请求的字符串目标并返回匹配的函数。如果它返回None
或引发异常,则会向请求者返回未知的服务响应。希望这能在一定程度上为您的需求奠定基础。
If I understand your question correctly, in order to achieve this, you are going to need to to override
getServiceRequest
on the Gateway class that you are using:self.router
is a function that you supply to the constructor of the gateway. It takes the string target of the AMF remoting request and returns a matching function. If it returnsNone
or raises an exception, an unknown service response will be returned to the requestor.Hopefully this goes some way to laying the groundwork for what you require.
昨晚解决了!
Solved last night!