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); }); } }
public byte[] Send(byte[] bs) { NetWriter writer = NetWriter.Instance; SetActionHead(writer); writer.SetBodyData(bs); return(writer.PostData()); }
public byte[] Send(Google.Protobuf.IMessage pbData) { NetWriter writer = NetWriter.Instance; SetActionHead(writer, pbData); writer.SetBodyData(PackCodec.Serialize(pbData)); return(writer.PostData()); }
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); }
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); }
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); }
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); }
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)); } }
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); }
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); } }
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); }
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); } }
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); } }
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; }); } }
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); }
protected override void SendParameter(NetWriter writer, ActionParam userData) { byte[] data = ProtoBufUtils.Serialize(userData.GetValue<LoginMessage>()); writer.SetBodyData(data); }