当前位置: 首页 > 工具软件 > PyAMF > 使用案例 >

pyamf

甘骞尧
2023-12-01
[color=red]pyamf和Flex交互的简单例子[/color]
Python端代码:
image_service.py
class ImageService(object):
def sayHello(self):
print "hello"


server.py
from image_service import ImageService
from pyamf.remoting.gateway.wsgi import WSGIGateway
from wsgiref import simple_server

if __name__ == '__main__':
services = { 'image_service' : ImageService}
gw = WSGIGateway(services)

httpd = simple_server.WSGIServer(
('localhost', 8000),
simple_server.WSGIRequestHandler,
)

httpd.set_app(gw)

print "Running PocketFlexDemoServer AMF gateway on http://localhost:8000"

try:
httpd.serve_forever()
except KeyboardInterrupt:
pass


Flex端代码:
只列出关键代码:
	<fx:Declarations>
<mx:RemoteObject id="remotImageService" destination="image_service" endpoint="http://localhost:8000">
<mx:method name="sayHello" result="onRemoteHelloResult(event)" fault="onDataError(event)"/>
</mx:RemoteObject>
</fx:Declarations>

private function sayHello():void
{
remotImageService.sayHello();
}
<s:Button label="Button" click="sayHello()"/>


[color=red]如何从pyamf.amf3.ByteArray取出实际的数据?[/color]
调用它的getvalue()函数。

ByteArray的结构如下图所示:
[img]http://dl.iteye.com/upload/attachment/303669/0a8c58e2-5256-3bd3-a5a6-6c808e7601f3.png[/img]
 类似资料:

相关阅读

相关文章

相关问答