• Networking table line by line
    4 replies, posted
Was here yesterday trying to learn some networking [URL="http://facepunch.com/showthread.php?t=1447112"]here[/URL], and after that post I was able to get the result I wanted (transferring a table from server to client). However, after looking and toying around with the file size, I noticed I cam out with this result. when I was transferring a table greater then 64kb. [IMG]http://i.gyazo.com/f03ea1a674f5691f24b1089f77e71454.png[/IMG] I figure I can eliminate this problem by send a table row by row, but since I'm still fairly new to networking, how would I go about dissecting the table to network to the client? Below is what I have originally: client.lua [CODE]// net recieve for TodaysLog net.Receive( "TodaysLog", function( bits ) for _, line in ipairs( net.ReadTable() ) do if(line[2] == os.date("%m-%d"))then logged:AddLine( unpack( line ) ) end end end )[/CODE] server.lua [CODE] util.AddNetworkString( "TodaysLog" ) function NetTodaysLog(ply) net.Start( "TodaysLog" ) if(os.date("%B") == "January" )then net.WriteTable( ipLogger.January ) elseif(os.date("%B") == "February" )then net.WriteTable( ipLogger.February ) elseif(os.date("%B") == "March" )then net.WriteTable( ipLogger.March ) elseif(os.date("%B") == "April" )then net.WriteTable( ipLogger.April ) elseif(os.date("%B") == "May" )then net.WriteTable( ipLogger.May ) elseif(os.date("%B") == "June" )then net.WriteTable( ipLogger.June ) elseif(os.date("%B") == "July" )then net.WriteTable( ipLogger.July ) elseif(os.date("%B") == "August" )then net.WriteTable( ipLogger.August ) elseif(os.date("%B") == "September" )then net.WriteTable( ipLogger.September ) elseif(os.date("%B") == "October" )then net.WriteTable( ipLogger.October ) elseif(os.date("%B") == "November" )then net.WriteTable( ipLogger.November ) elseif(os.date("%B") == "December" )then net.WriteTable( ipLogger.December ) end net.Send( ply ) -- send the message ONLY to the player that requested it end net.Receive( "TodaysLog", function( bits, ply ) local x = ipLogger.CanAccess(ply) if (x == true) then -- change the check to whatever you're wanting to limit this info by NetTodaysLog( ply ) end end) [/CODE] Logically wise, I assume I can go row by row and wait till I get a nil value [CODE] for _, line in ipairs (iplogger.January) do if(line[1] == nil ) then return end -- send table row end [/CODE] Other then that, this is the only way I could think of how to get around the 65kb message cap. Could anyone give me an idea where I should go or look at for more information on how to do this?
Divide your data into 64KB packets.. ( send multiple net messages )
[QUOTE=Robotboy655;46967642]Divide your data into 64KB packets.. ( send multiple net messages )[/QUOTE] I understand that, and that's what I want to end up doing. However, I think I phrased my problem poorly. I understand that there is a 64Kb cap, and the information I want to send is larger then that cap. I understand net.WriteTable() writes a full table, however I guess I can write a temp table to do what I want. Maybe something along the line of: [CODE] net.Start("TodaysLog") for _, line in ipairs (iplogger.January) do temp = {} temp = {line[1],line[2],line[3],line[4],line[5],line[6]} net.WriteTable(temp) -- send table row net.Send(ply) end [/CODE] But what I'm not sure is that once I dissect the row will the net.Send(ply) continuously send the table rows or does it close itself after the first net.Send? Once again, I'm still fairly new at this library so my understanding is still kindof limited.
net.Send() will "close" the message and send it to client.
So since the message is closed, do I need to call net.Start("TodaysLog") to open up the message to be sent to the client again? Or does it need to opened up again before I can send the next line of the table? Such as this: [CODE] for _, line in ipairs (iplogger.January) do net.Start("TodaysLog") temp = {} temp = {line[1],line[2],line[3],line[4],line[5],line[6]} net.WriteTable(temp) -- send table row net.Send(ply) end [/CODE] [editline]19th January 2015[/editline] Do I need to do anything on the client side for the recieving side? Because now when I request the table, It doesn't print out any rows as it once did when I sent the full table.
Sorry, you need to Log In to post a reply to this thread.