编码与解码
自定义的类型映射
- amfast支持用户自定义的对象类型。
- 使用 amfast.class_def.ClassDef对象,以达到用户自定义对象的序列化与反序列化。
- 使用ClassDefMapper将一个amfast.class_def.ClassDef与一个客户端的对象映射起来。
from amfast import class_def
# ClassDefMapper objects keep track of ClassDefs
class_mapper = class_def.ClassDefMapper()
# Map a custom class with static attributes
class_mapper.mapClass(class_def.ClassDef(MyCustomClass, 'class.alias', ('tuple', 'of', 'static', 'attribute', 'names')))
# Object attributes can be automatically converted
# to/from a specific type with the
# encode_types and decode_types attributes.
#
# encode_types and decode_types are dictionaries where
# the keys are the names of the attributes to convert,
# and the values are functions that will perform the conversion.
mapped_class = class_def.ClassDef(MyCustomClass, 'class.alias'....
mapped_class.encode_types = {'attribute_to_convert_to_int_before_encoding': int}
mapped_class.decode_types = {'attribute_to_convert_to_int_after_decoding': int}
# Map a custom class with dynamic attributes
class_mapper.mapClass(class_def.DynamicClassDef(MyCustomClass, 'class.alias', ()))
# Map a custom class implementing IExternalizable
# ExternClassDef must be sub-classed, and the
# methods readExternal and writeExternal must be implemented.
class_mapper.mapClass(class_def.ExternClassDef(MyCustomClass,'class.alias'))
# Map a custom class that is also mapped with SQLAlchemy.
# Attributes mapped with SQLAlchemy will automatically be
# added to the list of static attributes.
class_mapper.mapClass(class_def.sa_class_def.SaClassDef(MyCustomClass, 'class.alias')
# Attach ClassDefMapper to Encoder and Decoder
# objects to use the ClassDefMapper for encoding
# and decoding
encoder.class_def_mapper = class_mapper
decoder.class_def_mapper = class_mapper
# Use custom class mappings with a Channel
channel = channel_set.getChannel('channel_name')
channel.endpoint.encoder.class_def_mapper = class_mapper
channel.endpoint.decoder.class_def_mapper = class_mapper
分享到:
相关推荐
Encode_ Decode Tools URL编码解码工具
Video Encode and Decode GPU Support Matrix.xlsx
HDB3 ENCODE AND DECODE,详细设计与实现,参考一下下啊
alfred-encode-decode-workflow, 将sting编码和解码为多个变体 编码/解码( 下载 v1.8 )将字符串编码和解码为多个变体。要求Alfred应用程序 v2 。安装点击下面的下载按钮双击以导入 Alfred 2查看工作流以添加自定义...
Turbo lte encode decode
DVI 1.0 encode and decode source code, write with verilog, with simulation project, synplify project and all soure code. They're have been running on xilinx spartan3A FPGA. Can be used in real project...
C# Encoder 与 Decoder的例子,详细注释。 Encoder Decoder 编码 解码 C# Encoder Decoder 编码 解码 C# Encoder Decoder 编码 解码 C# Encoder Decoder 编码 解码 C#
jpeg 编码解码,用c/c++实现,读取bmp文件,压缩成为jpeg文件,再从jpeg文件解码为bmp文件
htmlencode、htmldecode,html编码,可以方便在web页面,显示html源码,一般将<>&单引号,双引号进行转码。这也是防止html注入攻击一个好方法!
bch decode and encode including simple description info.
using labview to encode DTMF tone and play through sound card and record DTMF tone from sound card and decode.
Encode_Decode_Tools_编码转换器 非常实用 方便!
js中encode、decode的应用说明.docx
编码/解码工具 @huayang V1.0 huayang 2021.4.10-2021.4.17 小工具,原创,解码/编码,解密 工具 项目介绍 一共两个版本分别是windows及mac版本,已经分别编译好了点击右方的Releases选择版本下载即可直接食用 实现功能...
microsoft Mpeg4 V2 Encode and Decode
UrlEncodeUrlDecodeUrl解码Url编码工具 基于UrlEncode,UrlDecode的解码编码工具,支持双向。
8b10_dec.vhd 8b10_enc.vhd 8b10b_encdec_v1d0.pdf enc_8b10b_TB.vhd encdec_8b10b_TB.vhd
前向纠错编码(FEC)技术通过在传输码列中加入冗余纠错码,在一定条件下,通过解码可以自动纠正传输误码,降低接收信号的误码率(BER)。 本算法每8bit增加4bit监督位,就纠错1bit
快速编码和解码Base64字符串。 Chrome扩展程序是一个简单的Base64编码器和解码器。 通过选择并右键单击所选内容,可对任何页面中的内联字符串进行编码和解码。 编码或解码字符串,使其符合Base64数据编码规范(RFC ...
在线protobuf编码/解码工具。 进入根目录,通过以下命令启动。 bower install serve