Post 2211603 by pea@fuckonthefirst.date
 (DIR) More posts by pea@fuckonthefirst.date
 (DIR) Post #2211128 by pea@fuckonthefirst.date
       2018-12-23T08:02:30.373421Z
       
       0 likes, 0 repeats
       
       now to figure out exactly how i'm gonna parse these packetsvarints/varlongs make it annoying and mean i can't just use straight pattern matching and i h a t e it
       
 (DIR) Post #2211141 by pea@fuckonthefirst.date
       2018-12-23T08:04:11.268669Z
       
       0 likes, 0 repeats
       
       I guess i could just,match the packet idthen go on from there
       
 (DIR) Post #2211147 by pea@fuckonthefirst.date
       2018-12-23T08:04:27.252784Z
       
       0 likes, 0 repeats
       
       oh wait but the packet id is a varint too because fuck you
       
 (DIR) Post #2211170 by ivesen@miniwa.moe
       2018-12-23T08:05:44.355940Z
       
       0 likes, 0 repeats
       
       @pea what kind of evil format are you parsing now? :blobpeek:
       
 (DIR) Post #2211360 by pea@fuckonthefirst.date
       2018-12-23T08:16:01.216700Z
       
       0 likes, 0 repeats
       
       so, my brain is thinking something like this makes senseprocess_data will have a pattern match for each packet type, which, y'know, will be a nightmare, but whateverprocess_packet(Packet) ->{ok, _, P2} = read_varint(Packet), % discard length{ok, PacketId, P3} = read_varint(P2),{ok, PacketType} = packet_id_to_atom(PacketId),{ok, Data} = process_data(PacketType, P3),{ok, {PacketType, Data}}.
       
 (DIR) Post #2211379 by pea@fuckonthefirst.date
       2018-12-23T08:17:07.800878Z
       
       0 likes, 0 repeats
       
       All the "okays" might be overdoing it actually, in retrospect most of those can't technically fail
       
 (DIR) Post #2211386 by pea@fuckonthefirst.date
       2018-12-23T08:17:22.231823Z
       
       0 likes, 0 repeats
       
       *oks
       
 (DIR) Post #2211414 by weykent@vulpine.club
       2018-12-23T08:18:21Z
       
       0 likes, 0 repeats
       
       @pea couuuuuuld this be a use case for code generation?
       
 (DIR) Post #2211415 by pea@fuckonthefirst.date
       2018-12-23T08:19:01.390223Z
       
       0 likes, 0 repeats
       
       @weykent it's possible, but complicated in my brain so far
       
 (DIR) Post #2211456 by pea@fuckonthefirst.date
       2018-12-23T08:21:20.876399Z
       
       0 likes, 0 repeats
       
       @weykent i'm honestly not really super aware of any of erlang's code generation facilitiesi know erlang *has* macrosit's also possible that I could use a datastructure that it reads from maybe to do these things? I still have to think over the options, but it's awful late so probably tomorrow
       
 (DIR) Post #2211530 by pea@fuckonthefirst.date
       2018-12-23T08:24:22.596787Z
       
       0 likes, 0 repeats
       
       @weykent like, normally pattern matching is astounding for dealing with thisyou could literally do almost nothing and have everything be perfectlegit just...process_packet(<<_:8, PacketId:8, Data/binary>>) ->{packet_id_to_atom(PacketId), Data}
       
 (DIR) Post #2211561 by pea@fuckonthefirst.date
       2018-12-23T08:25:28.549723Z
       
       0 likes, 0 repeats
       
       @weykent but because of varints (expl below) that all breaksVarInts:1 bit indicates whether there's another byte to the varint, the remaining 7 are the actual data
       
 (DIR) Post #2211603 by pea@fuckonthefirst.date
       2018-12-23T08:28:09.099594Z
       
       0 likes, 0 repeats
       
       @weykent so01101011 is an 8 bit varint, but you can also have1011010101101000 because it's [ (1)10110101, (0)1101000 ], the (1) meaning it continues
       
 (DIR) Post #2211605 by weykent@vulpine.club
       2018-12-23T08:27:31Z
       
       0 likes, 0 repeats
       
       @pea ooooof. is this protobufs..?i've heard erlang is superb for wire protocols but i don't know all the details. maybe it's trickier with variable lengths
       
 (DIR) Post #2211606 by pea@fuckonthefirst.date
       2018-12-23T08:28:32.487151Z
       
       0 likes, 0 repeats
       
       @weykent oh good idea, i should check out how the erlang implementation of protobufs works
       
 (DIR) Post #2211981 by pea@fuckonthefirst.date
       2018-12-23T08:48:40.803206Z
       
       0 likes, 0 repeats
       
       @weykent to be entirely honest, I could absolutely just do something janky and hacky since I know the max values that are gonna be sent over in these varints
       
 (DIR) Post #2212043 by pea@fuckonthefirst.date
       2018-12-23T08:51:17.191340Z
       
       0 likes, 0 repeats
       
       @weykent well, I actually also know the max number of bytes they can take, hmmmm