public byte[] Send(byte[] bs) { NetWriter writer = NetWriter.Instance; SetActionHead(writer); writer.SetBodyData(bs); return(writer.PostData()); }
public byte[] Send(object userData) { NetWriter writer = NetWriter.Instance; SetActionHead(writer); SendParameter(writer, userData); return(writer.PostData()); }
public byte[] Send(ActionParam actionParam) { NetWriter writer = NetWriter.Instance; SetActionHead(writer); SendParameter(writer, actionParam); return(writer.PostData()); }
public byte[] BuildHearbeatPackage() { NetWriter writer = NetWriter.Instance; writer.writeInt32("actionId", 1); byte[] data = writer.PostData(); NetWriter.resetData(); return(data); }
static int PostData(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 0); NetWriter writer = (NetWriter)LuaScriptMgr.GetNetObjectSelf(L, 1, "NetWriter"); byte[] objs = writer.PostData(); LuaScriptMgr.PushArray(L, objs); return(1); }
public byte[] Send(Google.Protobuf.IMessage pbData) { NetWriter writer = NetWriter.Instance; SetActionHead(writer, pbData); writer.SetBodyData(PackCodec.Serialize(pbData)); return(writer.PostData()); }
static int PostData(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); NetWriter obj = (NetWriter)ToLua.CheckObject <NetWriter>(L, 1); byte[] o = obj.PostData(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private void SendHeartbeatPackage(object state) { try { NetWriter writer = NetWriter.Instance; writer.writeInt32("actionId", 1); byte[] data = writer.PostData(); NetWriter.resetData(); if (!PostSend(data)) { Debug.Log("send heartbeat paketage fail"); } } catch (Exception ex) { Debug.LogException(ex); } }
private byte[] GetRequestData() { // if (isCustom) { return(netWriter.PostData()); } // StringBuilder param = new StringBuilder(); // var pairs = _params.ToArray(); // foreach (var pair in pairs) // { // if (param.Length > 0) // { // param.Append("&"); // } // param.AppendFormat("{0}={1}", pair.Key, NetProxy.Encoding(pair.Value)); // } // return Encoding.UTF8.GetBytes(string.Format("?d={0}", NetProxy.GetSign(param.ToString(), _session.Setting.SignKey))); }
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); }