public void PackToMessage(Packer pk, PackingOptions options) { pk.PackArrayHeader(5); pk.PackString(uri); pk.PackString(title); pk.Pack(width); pk.Pack(height); pk.Pack(size); }
public void PackToMessage( Packer pk, PackingOptions options ) { pk.PackArrayHeader( 5 ); pk.PackString( uri ); pk.PackString( title ); pk.Pack( width ); pk.Pack( height ); pk.Pack( size ); }
public void PackToMessage(Packer packer, PackingOptions options) { packer.PackMapHeader(3); packer.PackString("graphName"); packer.Pack(this.graphName); packer.PackString("graphObjName"); packer.Pack(this.graphObjName); packer.PackString("killSession"); packer.Pack(this.killSession); }
public void PackToMessage( Packer packer, PackingOptions options ) { // Pack fields are here: // First, record total fields size. packer.PackArrayHeader( 2 ); packer.Pack( this.Id ); packer.PackString( this.Name ); // ...Instead, you can pack as map as follows: // packer.PackMapHeader( 2 ); // packer.Pack( "Id" ); // packer.Pack( this.Id ); // packer.Pack( "Name" ); // packer.Pack( this.Name ); }
public void PackToMessage(Packer packer, PackingOptions options) { packer.PackMapHeader(this.inSession ? 4 : 6) .PackString("channel") .Pack(Channel.MsgPack) .PackString("inSession") .Pack(this.inSession) .PackString("isolate") .Pack(this.isolate) .PackString("transaction") .Pack(this.transaction); if (!this.inSession) { packer.PackString("graphName") .PackString(this.graphName) .PackString("graphObjName") .PackString(this.graphObjName); } }
/// <summary> /// Use msgpack to compress the data /// </summary> /// <param name="packer"> /// The msgpack packer /// </param> /// <param name="options"> /// msgpack packing options /// </param> public void PackToMessage(Packer packer, PackingOptions options) { packer.PackArrayHeader(this.Values.Count); foreach (object obj in this.Values) { if (obj.GetType() == typeof(string)) { string temp = (string)obj; packer.PackString(temp, Encoding.GetEncoding("UTF-8")); } else if (obj.GetType() == typeof(Single)) { float temp = (Single)obj; packer.Pack<float>(temp); } else if (obj.GetType() == typeof(int)) { int temp = (Int32)obj; packer.Pack(temp); } } }
/// <summary> /// Use msgpack to compress the data /// </summary> /// <param name="packer"> /// The msgpack packer /// </param> /// <param name="options"> /// msgpack packing options /// </param> public void PackToMessage(Packer packer, PackingOptions options) { packer.PackArrayHeader(this.Values.Count); foreach (MessagePackObject obj in this.Values) { if (obj.IsTypeOf(typeof(string)) == true) { string temp = obj.AsStringUtf8(); packer.PackString(temp); } else if (obj.IsTypeOf(typeof(Single)) == true) { float temp = obj.AsSingle(); packer.Pack<float>(temp); } else if (obj.IsTypeOf(typeof(int)) == true) { int temp = obj.AsInt32(); packer.Pack(temp); } } }
public void PackToMessage(Packer packer, PackingOptions options) { packer.Pack(count); packer.PackString(data); }
void Pack(Packer packer, object o) { if (o == null) { packer.PackNull(); return; } if (o is int) packer.Pack ((int)o); else if (o is uint) packer.Pack ((uint)o); else if (o is float) packer.Pack ((float)o); else if (o is double) packer.Pack ((double)o); else if (o is long) packer.Pack ((long)o); else if (o is ulong) packer.Pack ((ulong)o); else if (o is bool) packer.Pack ((bool)o); else if (o is byte) packer.Pack ((byte)o); else if (o is sbyte) packer.Pack ((sbyte)o); else if (o is short) packer.Pack ((short)o); else if (o is ushort) packer.Pack ((ushort)o); else if (o is string) packer.PackString((string)o, Encoding.ASCII); else if (o is Dictionary<string, object>) { packer.PackMapHeader((o as Dictionary<string, object>).Count); foreach (var pair in (o as Dictionary<string, object>)) { Pack(packer, pair.Key); Pack(packer, pair.Value); } } else if (o is string[]) { packer.PackArrayHeader((o as string[]).Length); foreach (var obj in (o as string[])) packer.Pack(obj as string); } else throw new Exception("Cant handle type: " + o.GetType().Name);; }