コード例 #1
0
ファイル: Action1001.cs プロジェクト: liamzhu/LePing
 protected override void SendParameter(NetWriter writer, ActionParam actionParam)
 {
     if (actionParam.HasValue)
     {
         //自定对象参数格式
         isCustom = true;
         Request1001Pack requestPack = new Request1001Pack()
         {
             PageIndex = 1,
             PageSize  = 10
         };
         byte[] data = ProtoBufUtils.Serialize(requestPack);
         writer.SetBodyData(data);
     }
     else
     {
         isCustom = false;
         //默认url参数格式
         actionParam.Foreach((k, v) =>
         {
             writer.writeString(k, v.ToString());
             return(true);
         });
     }
 }
コード例 #2
0
    public byte[] Send(byte[] bs)
    {
        NetWriter writer = NetWriter.Instance;

        SetActionHead(writer);
        writer.SetBodyData(bs);
        return(writer.PostData());
    }
コード例 #3
0
    public byte[] Send(Google.Protobuf.IMessage pbData)
    {
        NetWriter writer = NetWriter.Instance;

        SetActionHead(writer, pbData);

        writer.SetBodyData(PackCodec.Serialize(pbData));
        return(writer.PostData());
    }
コード例 #4
0
ファイル: NetWriterWrap.cs プロジェクト: jallenzhang/project3
    static int SetBodyData(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(byte[])))
        {
            NetWriter writer = (NetWriter)LuaScriptMgr.GetNetObjectSelf(L, 1, "NetWriter");
            byte[]    objs0  = LuaScriptMgr.GetArrayNumber <byte>(L, 1);
            writer.SetBodyData(objs0);
        }

        return(0);
    }
コード例 #5
0
ファイル: BaseAction.cs プロジェクト: houguohua/Scut
 protected override void SetActionHead(NetWriter writer)
 {
     MessagePack headPack = new MessagePack()
     {
         MsgId = Head.MsgId,
         ActionId = ActionId,
         SessionId = Head.SessionId,
         UserId = Head.UserId
     };
     byte[] data = ProtoBufUtils.Serialize(headPack);
     writer.SetHeadBuffer(data);
     writer.SetBodyData(null);
 }
コード例 #6
0
    protected override void SetActionHead(NetWriter writer)
    {
        ProtoHeadPack headPack = new ProtoHeadPack()
        {
            MsgId     = Head.MsgId,
            ActionId  = ActionId,
            SessionId = Head.SessionId,
            UserId    = Head.UserId
        };

        byte[] data = ProtoBufUtils.Serialize(headPack);
        writer.SetHeadBuffer(data);
        writer.SetBodyData(null);
    }
コード例 #7
0
    protected override void SetActionHead(NetWriter writer)
    {
        //todo 启用自定的结构
        package headPack = new package()
        {
            session   = Head.MsgId,
            protoId   = ActionId,
            errorcode = 0,
        };

        byte[] data = headPack.encode();
        writer.SetHeadBuffer(data);
        writer.SetBodyData(null);
    }
コード例 #8
0
 static int SetBodyData(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         NetWriter obj  = (NetWriter)ToLua.CheckObject <NetWriter>(L, 1);
         byte[]    arg0 = ToLua.CheckByteBuffer(L, 2);
         obj.SetBodyData(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #9
0
    protected override void SendParameter(NetWriter writer, ActionParam actionParam)
    {
        object obj = actionParam["obj"];
        int    cts = actionParam.Get <int>("cts");

        byte[] response = new byte[1];
        response[0] = actionParam.Get <bool>("response") ? (byte)1 : (byte)0;
        byte[] ctsBytes = BitConverter.GetBytes(cts);
        byte[] data     = ProtoBufUtils.Serialize(obj);
        byte[] bd       = new byte[ctsBytes.Length + 1 + data.Length];
        ctsBytes.CopyTo(bd, 0);
        response.CopyTo(bd, ctsBytes.Length);
        data.CopyTo(bd, ctsBytes.Length + 1);

        writer.SetBodyData(bd);
    }
コード例 #10
0
 protected override void SendParameter(NetWriter writer, ActionParam actionParam)
 {
     if (actionParam.HasValue)
     {
         //自定对象参数格式
         isCustom = true;
         var rankData = actionParam.GetValue<RankData>();
         byte[] data = ProtoBufUtils.Serialize(rankData);
         writer.SetBodyData(data);
     }
     else
     {
         isCustom = false;
         writer.writeString("UserName", "Jon");
         writer.writeInt32("Score", 100);
     }
 }
コード例 #11
0
    protected override void SetActionHead(NetWriter writer)
    {
        //todo 启用自定的结构;
        CTSPackageHead headPack = new CTSPackageHead()
        {
            MsgId     = Head.MsgId,
            ActionId  = ActionId,
            SessionId = Head.SessionId,
            UserId    = Head.UserId
        };

        byte[] data = ProtoBufUtils.Serialize(headPack);
        writer.SetHeadBuffer(data);
        writer.SetBodyData(null);

        //base.SetActionHead(writer);
    }
コード例 #12
0
 protected override void SendParameter(NetWriter writer, ActionParam actionParam)
 {
     if (actionParam.HasValue)
     {
         //自定对象参数格式
         isCustom = true;
         var    rankData = actionParam.GetValue <RankData>();
         byte[] data     = ProtoBufUtils.Serialize(rankData);
         writer.SetBodyData(data);
     }
     else
     {
         isCustom = false;
         writer.writeString("UserName", "Jon");
         writer.writeInt32("Score", 100);
     }
 }
コード例 #13
0
ファイル: Action1001.cs プロジェクト: jinfei426/Scut
 protected override void SendParameter(NetWriter writer, object userData)
 {
     if (isCustom)
     {
         //自定对象参数格式
         Request1001Pack requestPack = new Request1001Pack()
         {
             PageIndex = 1,
             PageSize = 10
         };
         byte[] data = ProtoBufUtils.Serialize(requestPack);
         writer.SetBodyData(data);
     }
     else
     {
         //默认url参数格式
         writer.writeInt32("PageIndex", 1);
         writer.writeInt32("PageSize", 10);
     }
 }
コード例 #14
0
ファイル: Action1001.cs プロジェクト: hackerlank/Scut
 protected override void SendParameter(NetWriter writer, object userData)
 {
     if (isCustom)
     {
         //自定对象参数格式
         Request1001Pack requestPack = new Request1001Pack()
         {
             PageIndex = 1,
             PageSize  = 10
         };
         byte[] data = ProtoBufUtils.Serialize(requestPack);
         writer.SetBodyData(data);
     }
     else
     {
         //默认url参数格式
         writer.writeInt32("PageIndex", 1);
         writer.writeInt32("PageSize", 10);
     }
 }
コード例 #15
0
ファイル: Action1001.cs プロジェクト: rambo-long/Scut
 protected override void SendParameter(NetWriter writer, ActionParam actionParam)
 {
     if (actionParam.HasValue)
     {
         //自定对象参数格式
         isCustom = true;
         Request1001Pack requestPack = actionParam.GetValue<Request1001Pack>();
         byte[] data = ProtoBufUtils.Serialize(requestPack);
         writer.SetBodyData(data);
     }
     else
     {
         isCustom = false;
         //默认url参数格式
         actionParam.Foreach((k, v) =>
         {
             writer.writeString(k, v);
             return true;
         });
     }
 }
コード例 #16
0
ファイル: Net.cs プロジェクト: liuzhognxiu/ThreeIdoits
    private void SocketRequest(int actionId, int actionRespId, LuaFramework.ByteBuffer body, LuaInterface.LuaFunction callback, IHeadFormater formater, bool bShowLoading)
    {
        if (mSocket == null)
        {
            string   url = NetWriter.GetUrl();
            string[] arr = url.Split(new char[] { ':' });
            if (arr.Length != 2)
            {
                Debug.LogError("Url is error:" + url);
                return;
            }
            int nPort = int.Parse(arr[1]);
            mSocket = new SocketConnect(arr[0], nPort, formater);
        }

        SocketPackage package = new SocketPackage();

        package.MsgId        = NetWriter.MsgId - 1;
        package.ActionId     = actionId;
        package.ActionRespId = actionRespId;
        package.HasLoading   = bShowLoading;
        package.SendTime     = DateTime.Now;
        package.Callback     = callback;

        NetWriter writer = NetWriter.Instance;

        SetActionHead(actionId, body);
        writer.SetBodyData(body.ToBytes());
        byte[] data = writer.PostData();
        NetWriter.resetData();

        if (bShowLoading)
        {
            RequestDelegate(Status.eStartRequest);
        }
        mSocket.Send(data, package);
    }
コード例 #17
0
 protected override void SendParameter(NetWriter writer, ActionParam userData)
 {
     byte[] data = ProtoBufUtils.Serialize(userData.GetValue<LoginMessage>());
     writer.SetBodyData(data);
 }