示例#1
0
        //---------------------------------------------------------------------
        public void rpcBySession <T1>(IRpcSession session, ushort method_id, T1 obj1)
        {
            byte[] data = null;

            using (MemoryStream s = new MemoryStream())
            {
                try
                {
                    ProtoBuf.Serializer.Serialize <T1>(s, obj1);
                    data = s.ToArray();
                }
                catch (Exception ex)
                {
                    EbLog.Note("Component.rpcBySession<T1>() Serializer Error! MethodId="
                               + method_id + " Exception:" + ex.ToString());
                    EbLog.Note("Type1=" + typeof(T1).Name);
                    return;
                }
            }

            if (session != null)
            {
                session.send(method_id, data);
            }
        }
示例#2
0
        //---------------------------------------------------------------------
        public void rpcBySession <T1, T2, T3, T4>(IRpcSession session, ushort method_id, T1 obj1, T2 obj2, T3 obj3, T4 obj4)
        {
            byte[] data = null;

            using (MemoryStream s = new MemoryStream())
            {
                try
                {
                    ProtoBuf.Serializer.SerializeWithLengthPrefix <T1>(s, obj1, ProtoBuf.PrefixStyle.Fixed32);
                    ProtoBuf.Serializer.SerializeWithLengthPrefix <T2>(s, obj2, ProtoBuf.PrefixStyle.Fixed32);
                    ProtoBuf.Serializer.SerializeWithLengthPrefix <T3>(s, obj3, ProtoBuf.PrefixStyle.Fixed32);
                    ProtoBuf.Serializer.SerializeWithLengthPrefix <T4>(s, obj4, ProtoBuf.PrefixStyle.Fixed32);
                    data = s.ToArray();
                }
                catch (Exception ex)
                {
                    EbLog.Error("Component.rpcBySession<T1,T2,T3,T4>() Serializer Error! MethodId="
                                + method_id + " Exception:" + ex.ToString());
                    EbLog.Error("Type1=" + typeof(T1).Name + " Type2=" + typeof(T2).Name
                                + " Type3=" + typeof(T3).Name + " Type4=" + typeof(T4).Name);
                    return;
                }
            }

            if (session != null)
            {
                session.send(method_id, data);
            }
        }
示例#3
0
 //---------------------------------------------------------------------
 public void rpcBySession(IRpcSession session, ushort method_id)
 {
     if (session != null)
     {
         session.send(method_id, null);
     }
 }