/// <summary> /// rebuild socket send hearbeat package /// </summary> public SocketPackage ReBuildHearbeat() { var writer = NetWriter.Instance; SprotoType.package headPack = new SprotoType.package() { protoId = 2, session = NetWriter.MsgId, errorcode = 0, }; Sproto.SprotoPack pack = new Sproto.SprotoPack(); byte[] headBytes = headPack.encode(); writer.SetHeadBuffer(headBytes); writer.SetBodyData(new byte[0]); var data = writer.PostData(); NetWriter.resetData(); _hearbeatPackage = data; SocketPackage package = new SocketPackage(); package.MsgId = (int)headPack.session; package.ActionId = 2; package.Action = ActionFactory.Create(package.ActionId); package.SendTime = DateTime.Now; package.HasLoading = false; return(package); }
public byte[] BuildHearbeatPackage() { var writer = NetWriter.Instance; SprotoType.package headPack = new SprotoType.package() { protoId = 2, session = NetWriter.MsgId, errorcode = 0, }; Sproto.SprotoPack pack = new Sproto.SprotoPack(); byte[] headBytes = headPack.encode(); writer.SetHeadBuffer(headBytes); writer.SetBodyData(new byte[0]); var data = writer.PostData(); NetWriter.resetData(); return(data); }