These are chat archives for ProtoDef-io/node-protodef

20th
Mar 2017
mhsjlw
@mhsjlw
Mar 20 2017 00:00
i really don't like that lol
Hans Elias J.
@hansihe
Mar 20 2017 00:00
it's a convension
i mean, you can do raknet, Raknet if you want
mhsjlw
@mhsjlw
Mar 20 2017 00:02
but wait, this is an application
how does McProtocol work
or should I not worry about that for now
Hans Elias J.
@hansihe
Mar 20 2017 00:03
what do you mean?
if you run the generator with --sup, you get a supervisor tree generated, yes
mhsjlw
@mhsjlw
Mar 20 2017 00:03
yes, but then I can't use this as a library
I'm creating an application
Hans Elias J.
@hansihe
Mar 20 2017 00:04
all erlang libraries are applications
not all applications have supervisor trees
mhsjlw
@mhsjlw
Mar 20 2017 00:04
ok, nevermind then
I don't know naming conventions but I really don't like how you do McEx with the single file inside of each folder
my process for a client should be called what ? rak_net_worker ?
no wait I need acceptor
rak_net_acceptor
Hans Elias J.
@hansihe
Mar 20 2017 00:06
single file inside of each folder?
mhsjlw
@mhsjlw
Mar 20 2017 00:06
for each module
ex. RakNet.Acceptor goes into lib/acceptor/rak_net_acceptor.ex
rather than lib/rak_net_acceptor.ex
Hans Elias J.
@hansihe
Mar 20 2017 00:07
RakNet.Acceptor would go into lib/rak_net/acceptor.ex
that's the convension
McEx doesn't follow that in some places, and that was something on my todo list for fixing
mhsjlw
@mhsjlw
Mar 20 2017 00:09
hmm
so ok
now would I want my acceptor to handle state, right ?
it handles a list of all connected clients?
so my acceptor is a genserver
ugh this is confusing me now
... hmm how to approach
Hans Elias J.
@hansihe
Mar 20 2017 00:10
just come up with a plan and try to implement it
if you decide you did it wrong, you can always change it later
mhsjlw
@mhsjlw
Mar 20 2017 00:12
yeah, i'm going to just write some code and then i'll think about it and probably end up rewriting it a couple times
Hans Elias J.
@hansihe
Mar 20 2017 00:12
I think you are stuck in planning hell, I was really bad at that before
mhsjlw
@mhsjlw
Mar 20 2017 00:12
I don't want to overthink it
yeah ^
@hansihe can you think of a datatype off the top of your head that would be good for ip->pid
and easy to remove as well.
?
Hans Elias J.
@hansihe
Mar 20 2017 00:17
map
mhsjlw
@mhsjlw
Mar 20 2017 00:17
is that fast though?
Hans Elias J.
@hansihe
Mar 20 2017 00:17
dude
worry about that if it becomes a problem
that's all the datatypes you have anyways
well, there is ets and stuff, but you can look at that later if needed
most likely it won't be a problem
mhsjlw
@mhsjlw
Mar 20 2017 00:19
you're right you're right I need to chill out
ok, so my acceptor is a genserver with a state of a socket and a map
on a data received I will check if it exists in the map if not , create a process, and put it in the table
if it does exist I send the data to the process with the socket
idk if that's right but I'm rolling with it right now
Hans Elias J.
@hansihe
Mar 20 2017 00:25
i would just have started with responding to pings
mhsjlw
@mhsjlw
Mar 20 2017 00:25
yeah that's what I'm doing
oh I see
okay yeah less complicated right now
mhsjlw
@mhsjlw
Mar 20 2017 00:58
so @hansihe i'm 100% i'm doing something wrong
but please take a look at
what do I do in the start link :P
wrong arity
def start_link(opts \\ []) do
that should do it
Hans Elias J.
@hansihe
Mar 20 2017 01:01
start_link is another convension
what it should do is spawn a new process and link to the caller
that's not what you are doing there
other than that, it looks good to me
you can put things like response and magic in @attributes
mhsjlw
@mhsjlw
Mar 20 2017 01:02
yeah I tried that
it did weird stuff saying it didn't exist
Hans Elias J.
@hansihe
Mar 20 2017 01:02
so @magic <<...>>
@magic
mhsjlw
@mhsjlw
Mar 20 2017 01:03
invalid write attribute syntax, you probably meant to use: @response expression
oh
lol i did =
(MatchError) no match of right hand side value: <<1, 0, 0, 0, 0, 0 ...
i think you mean convention by the way
you said convension twice i'm pretty sure you mean convention
Hans Elias J.
@hansihe
Mar 20 2017 01:05
i do, yes
convention
mhsjlw
@mhsjlw
Mar 20 2017 01:05
this is the culprit << identifier :: size(8), _ >> = packet
but like, ?!?!
that should work , right?
then it says no match
Hans Elias J.
@hansihe
Mar 20 2017 01:06
try <<identifier::binary-size(8), _::binary>>
it defaults to integer iirc
mhsjlw
@mhsjlw
Mar 20 2017 01:08
um
that identifier is not correct
are you sure binary size ?
i just want a uint
Hans Elias J.
@hansihe
Mar 20 2017 01:08
if you want an integer, then just remove the binary- part
mhsjlw
@mhsjlw
Mar 20 2017 01:08
yeah size is what I want
ok cool so i get unconnected pings and log them
but my response isn't correct apparently
because the client wont render it in mcpe
i64,i64,magic,string
<< @id_unconnected_pong, 1 :: size(64), 1 :: size(64), @magic, @response >>
oops
<< @id_unconnected_pong, 1 :: size(64), 1 :: size(64), @magic, @response >>
hmm
oh !
i know
mhsjlw
@mhsjlw
Mar 20 2017 01:15
what is [ 339724, -6627871 ] as a normal long @hansihe ?
do I just add them?
Hans Elias J.
@hansihe
Mar 20 2017 01:15
what are you trying to do
mhsjlw
@mhsjlw
Mar 20 2017 01:15
no .. wait it's the hi and lo
that's the server id
Hans Elias J.
@hansihe
Mar 20 2017 01:16
gemme the line of code
mhsjlw
@mhsjlw
Mar 20 2017 01:16
so
that's what I've got
The log output looks like it's sending the right things ?!
21:15:47.905 [info]  Got unconnected ping! With ID of 879658, <<0, 0, 0, 0, 0, 13, 108, 42, 0, 255, 255, 0, 254, 254, 254, 254, 253, 253, 253, 253, 18, 52, 86, 120, 0, 0, 0, 0, 16, 20, 214, 159>>

21:15:47.905 [info]  Sent back <<28, 0, 0, 0, 0, 0, 13, 108, 42, 0, 0, 0, 0, 0, 0, 0, 1, 0, 255, 255, 0, 254, 254, 254, 254, 253, 253, 253, 253, 18, 52, 86, 120, 77, 67, 80, 69, 59, 65, 32, 77, 105, 110, 101, 99, 114, 97, 102, 116, 58, ...>>
i think it's the server id
which is why I need to know the value of that long i sent you
Hans Elias J.
@hansihe
Mar 20 2017 01:19
which one is high and which is low?
and it's 32 bits each, right?
mhsjlw
@mhsjlw
Mar 20 2017 01:20
it's protodef
yeah
Hans Elias J.
@hansihe
Mar 20 2017 01:20
i don't know how node-protodef does it
mhsjlw
@mhsjlw
Mar 20 2017 01:20
hmm
one sec
   buffer.writeInt32BE(value[0], offset);
   buffer.writeInt32BE(value[1], offset + 4);
hi lo
i think
no idea
lolol
Hans Elias J.
@hansihe
Mar 20 2017 01:22
(339724 << 32) + -6627871
that's IF they are represented as i32
(339724 << 32) & -6627871
works too
(339724 << 32) | -6627871
sorry
Hans Elias J.
@hansihe
Mar 20 2017 01:27
<<int::unsigned-integer-size(64)>> = <<339724::signed-integer-size(32), -6627871::signed-integer-size(32)>>
if you wanted to use elixir binary syntax for it
mhsjlw
@mhsjlw
Mar 20 2017 01:30
thank you :)
William Gaylord
@wgaylord
Mar 20 2017 02:18
You could just read it as the long instead of reading it as two ints.
Hans Elias J.
@hansihe
Mar 20 2017 07:11
chibill: not in JavaScript, all numbers in there are f64 which don't have enough precision to represent an u64
William Gaylord
@wgaylord
Mar 20 2017 13:36
But he was not using javascript was he? He is using elixir.
For the python implementation I will just be using longs.
mhsjlw
@mhsjlw
Mar 20 2017 14:22
!??!??
yes elixir supports i64, I just needed to convert to u32 to q long
Romain Beaumont
@rom1504
Mar 20 2017 14:28
*two u32 to a long
(just saving the next person the 30s it took me to parse this :p)
William Gaylord
@wgaylord
Mar 20 2017 14:29
I am just confused why he would have two 32u. If he can read longs.
mhsjlw
@mhsjlw
Mar 20 2017 14:34
lmao
JavaScript doesn't have longs
Elixir does
I needed to convert the protodef array to an elixir long
Romain Beaumont
@rom1504
Mar 20 2017 14:35
mhsjlw: do you mean in the test examples ?
(that probably should have long instead of array)
(since json supports arbitrarly big numbers)
William Gaylord
@wgaylord
Mar 20 2017 14:37
Longs are just longs in the types. Not an int array. (Docs were a bit goofy about that for a bit)
ProtoDef-io/ProtoDef@00b63e5
Romain Beaumont
@rom1504
Mar 20 2017 14:37
yes
but there are still array in the tests, maybe he's talking about that
William Gaylord
@wgaylord
Mar 20 2017 14:38
Could be.
the tests technically have to be slightly different for each lang. (Ex. Javascript vs python) as some langs support longs or represent stuff diffrently.
welp I have to go to my calc 1 class after last week was my spring break. #ripme
Romain Beaumont
@rom1504
Mar 20 2017 14:40
no
William Gaylord
@wgaylord
Mar 20 2017 14:40
?
Romain Beaumont
@rom1504
Mar 20 2017 14:41
the tests can (and are) generic
they are just data .json file
then they can be used to actually implement tests in whatever language
calc 1
I wish I had a calc class to do :d
William Gaylord
@wgaylord
Mar 20 2017 14:42
So you have to convert the types in the tests manually to make them work.... (I am talking the actual protodef tests) In which a long is said to return two ints while in langs that support longs it would just return a long...
Romain Beaumont
@rom1504
Mar 20 2017 14:43
15:36 <rom1504> (that probably should have long instead of array)
15:36 <rom1504> (since json supports arbitrarly big numbers)
yes it will prob change
William Gaylord
@wgaylord
Mar 20 2017 14:44
Thats what I meant it needs to be slightly diffrent,,,
as in JavaScript you would still need to have the array there. Because it won't convert the long in the json to the array itself. (Or will it? I have not played with JS much)
Romain Beaumont
@rom1504
Mar 20 2017 14:47
ah now I remember
yeah it's indeed not possible without making a custom json parser
which might not really be hard but kind of annoying
oh that's issue 1
ProtoDef-io/ProtoDef#1
William Gaylord
@wgaylord
Mar 20 2017 15:10
Interesting... stupid langs not supporting new stuff... (and actually longs are not that new.)
Robin Lambertz
@roblabla
Mar 20 2017 15:25
long is old af.
It's more like, langs using broken abstractions
Python got it right by supporting arbitrarily large numbers.
William Gaylord
@wgaylord
Mar 20 2017 15:26
Python mostly followed C and so did Java.
JavaScript I have no idea.
https://github.com/chibill/python-protodef nothing there yet but there will be.
Basiclly I am going to port the JS impl as close as possible. (But still using pythons style of doing stuff.) As that will be simple. Then I will try and make one that spits out python code.
Robin Lambertz
@roblabla
Mar 20 2017 15:42
Python didn't follow C as far as numbers are concerned
Python's impl is pretty much aligned with how we treat numbers : something unlimited in length.
William Gaylord
@wgaylord
Mar 20 2017 15:43
Python longs are CLongs. (It will say an error after a while. (Well last time I checked last month))
Robin Lambertz
@roblabla
Mar 20 2017 15:44
AFAIK, no
They are bigints
at least in python3 they are
William Gaylord
@wgaylord
Mar 20 2017 15:45
Or maybe that's only when in the range function...
Robin Lambertz
@roblabla
Mar 20 2017 15:45
and people using python2 in 2017 need to die
:D
William Gaylord
@wgaylord
Mar 20 2017 15:45
....
Robin Lambertz
@roblabla
Mar 20 2017 15:45
The sys.maxint constant was removed, since there is no longer a limit to the value of integers. However, sys.maxsize can be used as an integer larger than any practical list or string index. It conforms to the implementation’s “natural” integer size and is typically the same as sys.maxint in previous releases on the same platform (assuming the same build options).
William Gaylord
@wgaylord
Mar 20 2017 15:45
By Py2 has all the libs.
And py3 as broken int division.
Robin Lambertz
@roblabla
Mar 20 2017 15:45
most libs are compatible with both
I haven't seen a single lib that wasn't in the past, what, 5 years ? at least
William Gaylord
@wgaylord
Mar 20 2017 15:46
Not the C based ones.
Robin Lambertz
@roblabla
Mar 20 2017 15:46
Like which ?
William Gaylord
@wgaylord
Mar 20 2017 15:46
And many are not that use urllib.
Robin Lambertz
@roblabla
Mar 20 2017 15:46
Y'know, I'm not going to enter this debate.
Just know that by using py2, you are contributing to the reason why python sucks.
:3
William Gaylord
@wgaylord
Mar 20 2017 15:47
How does pyrhon suck? Other then it's better then JS, 😝
Python*
Robin Lambertz
@roblabla
Mar 20 2017 15:47
py2 sucks
py3 is a great language with many modern features.
Although even py3 has a lot of faults. Like the GIL, making threads impossible.
William Gaylord
@wgaylord
Mar 20 2017 15:48
Really. Well the thing is most stuff is written for Py2. And also Py2 has GIL.
Robin Lambertz
@roblabla
Mar 20 2017 15:48
Yeah I know
William Gaylord
@wgaylord
Mar 20 2017 15:49
Only jython has no GIL. :D
Robin Lambertz
@roblabla
Mar 20 2017 15:49
stackless python has no GIL either IIRC
William Gaylord
@wgaylord
Mar 20 2017 15:49
Python written in Java the worst of both worlds.
Robin Lambertz
@roblabla
Mar 20 2017 15:49
And I can say I haven't encountered many software written in py2 in the past 5 years. I would know, as I actively refuse to install py2 on my machine
Why the hell would you use python2 anyway ? It lacks generators, async libs, etc...
William Gaylord
@wgaylord
Mar 20 2017 15:50
I only have been sticking to Py2 because it was all that was around when I started programming. In the past 10 years I have found tons, (even recently.)
It has generators...
Robin Lambertz
@roblabla
Mar 20 2017 15:50
hmm, maybe it has generators. But no async. And that makes efficient network programming a bitch
And no, twisted doesn't count.
That library's name is appropriate.
William Gaylord
@wgaylord
Mar 20 2017 15:51
Yep.
I have both Py2 and py3.
Installed.
Which were both 32 bit till recently. Because my one C depending lib finally recompiled the DLL it used for 64 bit.
Robin Lambertz
@roblabla
Mar 20 2017 15:52
Aah I remember now
yield from isn't in py2
William Gaylord
@wgaylord
Mar 20 2017 15:52
Yep only normal yield
Also Py2 apparently works with huge numbers...
Like so large they crash my pythonista app...
Trying to print them.
Now Haskell on the other hands is very fun.
Robin Lambertz
@roblabla
Mar 20 2017 15:55
Don't talk about haskell ;_; It's killing me right now
William Gaylord
@wgaylord
Mar 20 2017 15:58
Lol. I had to learn it for a class.
*have
Romain Beaumont
@rom1504
Mar 20 2017 16:00
I think haskell is fun, until you use it :p
William Gaylord
@wgaylord
Mar 20 2017 16:30
So I will also be implementing the Chunk section as a protocol.json to help make the map Chunk data packet better.
Maybe.
but it's not that greatly useful
also entity data are define in mc protocol.json, that's not part of the chunk buffer
William Gaylord
@wgaylord
Mar 20 2017 16:40
I know. (That makes the buffer size conditional.... )
Nvm
Also mobile is shit. You can edit of delete,
Robin Lambertz
@roblabla
Mar 20 2017 16:42
TBH, we should put chunk buffer parsing back into protocol.json
William Gaylord
@wgaylord
Mar 20 2017 16:42
Yeah. But some people claim it can't be done easily.
mhsjlw
@mhsjlw
Mar 20 2017 16:44
please use python 3
William Gaylord
@wgaylord
Mar 20 2017 16:45
... I like Py2 as it's what I have used for the past 10 years. Plus all my code I write works on both Py2 and py3. Unless it uses a Py2 only lib.
mhsjlw
@mhsjlw
Mar 20 2017 16:46
I want to use asyncio
William Gaylord
@wgaylord
Mar 20 2017 16:47
Also the block entities in the Map Chunk packet seems odd..... Hold to you divide that up in the array if you don't know the size of each NBTTag.
How not hold...
Romain Beaumont
@rom1504
Mar 20 2017 16:50
I don't think it should go in protocol.json for >=1.9 because then we'd have to do it for 1.8 too to be logical, and it's not at all logical (while much easier) for 1.8, because we have a js implementation of 1.8 chunk which doesn't require parsing the chunk
ah yeah I remember, making it optional or something
well maybe the day we have that feature I guess then
chibill: you don't know any size
I mean
you know all the sizes
whatever look at prismarine-nbt nbt.json
William Gaylord
@wgaylord
Mar 20 2017 16:52
I mean how do you make an array out of the bytes unless you can split it into the NBT tags.
William Gaylord
@wgaylord
Mar 20 2017 18:26
not sure what I should use in replace of the buffer used in the node version. As python buffers are a bit funny... And don't have functions that take offsets.
Robin Lambertz
@roblabla
Mar 20 2017 19:22
You could just use a byte string in python
@chibill
William Gaylord
@wgaylord
Mar 20 2017 19:41
maybe. But how well does that work with struct?
Robin Lambertz
@roblabla
Mar 20 2017 19:42
What do you mean ?
William Gaylord
@wgaylord
Mar 20 2017 19:43
I am using struct to read the bytes into actual types. so using byte strings I have to do goofy partitioning/ getting the correct part of the byte string. For it to unpack.
I was thinking of just using a file like object. As I can read and phrase the data easily.
Robin Lambertz
@roblabla
Mar 20 2017 19:44
ooh
you mean for the actual reading ?
Just use a stream
Right, an IO object
William Gaylord
@wgaylord
Mar 20 2017 20:02
will that slowly use up bytes in the stream? (So i don't have to play with offsets?)
Robin Lambertz
@roblabla
Mar 20 2017 20:02
yup
Streams work that way
the problem is that by default, streams are slow
because for each read, you're making a syscall
William Gaylord
@wgaylord
Mar 20 2017 20:03
I was going to just use a file object. But this stream stuff might work... Pretty weird looking but.
Robin Lambertz
@roblabla
Mar 20 2017 20:03
so what BufferedRead does is, it reads as much as it can right away
and then when you call read(4), it just emulates what the os would give you, but coming straight from its buffer
William Gaylord
@wgaylord
Mar 20 2017 20:05
Interesting.
Not sure whats better using file-like objects directly or that.
which would be a wrapper around the file-like object. (Socket / open file)
actually BufferedReader and BufferWriter has the same interface as a file-like object.
I long thought we shouldn't have this in protodef, but the more I think about it, the more I think we should actually have something like it