public static SpTypeManager Import(Stream stream) { SpTypeManager instance = new SpTypeManager(); new SpProtoParser(instance).Parse(stream); return(instance); }
public static SpTypeManager Import(string proto) { SpTypeManager instance = new SpTypeManager(); new SpProtoParser(instance).Parse(proto); return(instance); }
public SpField (string name, short tag, string type, bool table, string key, SpTypeManager m) { Name = name; Tag = tag; TypeName = type; IsTable = table; KeyName = key; mTypeManager = m; }
public Benchmark () { manager = LoadProto (); obj = CreateObject (); manager.Codec.Encode ("AddressBook", obj, encode_stream); encode_stream.Position = 0; SpPacker.Pack (encode_stream, pack_stream); pack_stream.Position = 0; SpPacker.Unpack (pack_stream, unpack_stream); }
private SpTypeManager LoadProto() { SpTypeManager tm = null; string path = Util.GetFullPath("foobar.sproto"); using (FileStream stream = new FileStream(path, FileMode.Open)) { tm = SpTypeManager.Import(stream); } return(tm); }
public SpField(string name, short tag, string type, bool table, string key, SpTypeManager m) { Name = name; Tag = tag; TypeName = type; IsTable = table; KeyName = key; mTypeManager = m; }
public Benchmark() { manager = LoadProto(); obj = CreateObject(); manager.Codec.Encode("AddressBook", obj, encode_stream); encode_stream.Position = 0; SpPacker.Pack(encode_stream, pack_stream); pack_stream.Position = 0; SpPacker.Unpack(pack_stream, unpack_stream); }
public void Run() { SpTypeManager server_tm = SpTypeManager.Import(server_proto); server = SpRpc.Create(server_tm, "package"); client = SpRpc.Create(client_proto, "package"); client.Attach(server_tm); TestFoobar(); TestFoo(); TestBar(); TestBlackhole(); }
public void Run() { string proto = @" .ss { a 0 : string } .ability { hp 0 : integer att 1 : integer } .attribute { templateId 0 : integer level 1 : integer ability 2 : ability } .character { id 0 : integer attribute 1 : attribute } .clist { character 0 : *character(id) } " ; manager = SpTypeManager.Import(proto); TestStr("12345678"); /* * TestNest (); * * TestStr (""); * TestStr ("123"); * TestStr ("123456"); * TestStr ("12345678"); * TestStr ("12345678123"); * TestStr ("12345678123456"); * TestStr ("1234567812345678"); * TestStr ("12345678123456781234567812345678"); * TestStr ("123456781234567812345678123456781"); * TestStr ("123456781234567812345678123456781234567"); */ }
public void Run() { SpTypeManager manager = LoadProto(); SpObject obj = CreateObject(); CheckObj(obj); Util.Log("Encode"); SpStream encode_stream = new SpStream(); manager.Codec.Encode("AddressBook", obj, encode_stream); encode_stream.Position = 0; Util.DumpStream(encode_stream); Util.Log("Decode"); encode_stream.Position = 0; SpObject newObj = manager.Codec.Decode("AddressBook", encode_stream); CheckObj(newObj); Util.Log("Pack"); encode_stream.Position = 0; SpStream pack_stream = new SpStream(); SpPacker.Pack(encode_stream, pack_stream); pack_stream.Position = 0; Util.DumpStream(pack_stream); Util.Log("Unpack"); pack_stream.Position = 0; SpStream unpack_stream = new SpStream(); SpPacker.Unpack(pack_stream, unpack_stream); unpack_stream.Position = 0; Util.DumpStream(unpack_stream); Util.Log("Decode"); unpack_stream.Position = 0; newObj = manager.Codec.Decode("AddressBook", unpack_stream); CheckObj(newObj); }
public static SpRpc Create(SpTypeManager tm, string package) { if (tm == null) { return(null); } SpType t = tm.GetType(package); if (t == null) { return(null); } SpRpc rpc = new SpRpc(tm, t); return(rpc); }
private SpRpc CreateProto(string subDir) { SpTypeManager c2SMgr; SpTypeManager s2CMgr; var c2S = _path + subDir + "/c2s.sproto"; using (var stream = new FileStream(c2S, FileMode.Open)) { c2SMgr = SpTypeManager.Import(stream); } var s2C = _path + subDir + "/s2c.sproto"; using (var stream = new FileStream(s2C, FileMode.Open)) { s2CMgr = SpTypeManager.Import(stream); } var rpc = SpRpc.Create(s2CMgr, "package"); rpc.Attach(c2SMgr); return(rpc); }
public static SpRpc Create(string proto, string package) { return(Create(SpTypeManager.Import(proto), package)); }
public void Run () { string proto = @" .ss { a 0 : string } .ability { hp 0 : integer att 1 : integer } .attribute { templateId 0 : integer level 1 : integer ability 2 : ability } .character { id 0 : integer attribute 1 : attribute } .clist { character 0 : *character(id) } "; manager = SpTypeManager.Import (proto); TestStr ("12345678");/* TestNest (); TestStr (""); TestStr ("123"); TestStr ("123456"); TestStr ("12345678"); TestStr ("12345678123"); TestStr ("12345678123456"); TestStr ("1234567812345678"); TestStr ("12345678123456781234567812345678"); TestStr ("123456781234567812345678123456781"); TestStr ("123456781234567812345678123456781234567"); */ }
public SpRpc(SpTypeManager tm, SpType t) { mHostTypeManager = tm; mHeaderType = t; }
public void Run() { SpTypeManager manager = LoadProto(); // different ways to create SpObject Util.Log("Object Create Check"); CheckObj(CreateObject()); CheckObj(CreateObject2()); SpObject obj = CreateObject3(); CheckObj(obj); Util.Log("Encode"); SpStream small_stream = new SpStream(32); bool success = manager.Codec.Encode("foobar", obj, small_stream); Util.Assert(success == false); Util.Log("encode failed! require size : " + small_stream.Position); small_stream.Position = 0; Util.DumpStream(small_stream); SpStream encode_stream = manager.Codec.Encode("foobar", obj); encode_stream.Position = 0; Util.DumpStream(encode_stream); Util.Log("Decode "); encode_stream.Position = 0; SpObject ooo = manager.Codec.Decode("foobar", encode_stream); CheckObj(ooo); Util.Log("Pack"); encode_stream.Position = 0; small_stream.Position = 0; success = SpPacker.Pack(encode_stream, small_stream); Util.Assert(success == false); Util.Log("pack failed! require size : " + small_stream.Position); small_stream.Position = 0; Util.DumpStream(small_stream); SpStream pack_stream = SpPacker.Pack(encode_stream); pack_stream.Position = 0; Util.DumpStream(pack_stream); Util.Log("Unpack"); pack_stream.Position = 0; small_stream.Position = 0; success = SpPacker.Unpack(pack_stream, small_stream); Util.Assert(success == false); Util.Log("unpack failed! require size : " + small_stream.Position); small_stream.Position = 0; Util.DumpStream(small_stream); pack_stream.Position = 0; SpStream decode_stream = SpPacker.Unpack(pack_stream); decode_stream.Position = 0; Util.DumpStream(decode_stream); Util.Log("Decode "); decode_stream.Position = 0; SpObject newObj = manager.Codec.Decode("foobar", decode_stream); CheckObj(newObj); }
public void Attach(string proto) { Attach(SpTypeManager.Import(proto)); }
public void Attach(SpTypeManager tm) { mAttachTypeManager = tm; }
public void Attach (SpTypeManager tm) { mAttachTypeManager = tm; }
public SpRpc (SpTypeManager tm, SpType t) { mHostTypeManager = tm; mHeaderType = t; }
public static SpRpc Create (SpTypeManager tm, string package) { if (tm == null) return null; SpType t = tm.GetType (package); if (t == null) return null; SpRpc rpc = new SpRpc (tm, t); return rpc; }
public SpCodec (SpTypeManager m) { mTypeManager = m; }
public SpCodec(SpTypeManager m) { mTypeManager = m; }