aedigix has quit [Remote host closed the connection]
aedigix has joined #ponylang
jemc has joined #ponylang
jemc has quit [Ping timeout: 260 seconds]
chemist69 has quit [Ping timeout: 240 seconds]
chemist69 has joined #ponylang
jemc has joined #ponylang
_whitelogger has joined #ponylang
gmcabrita has quit [Quit: Connection closed for inactivity]
jemc has quit [Ping timeout: 256 seconds]
_whitelogger has joined #ponylang
_whitelogger has joined #ponylang
_whitelogger has joined #ponylang
prettyvanilla has quit [Remote host closed the connection]
prettyvanilla has joined #ponylang
gmcabrita has joined #ponylang
Praetonus has joined #ponylang
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
chemist69 has quit [Ping timeout: 260 seconds]
plietar has quit [Ping timeout: 264 seconds]
chemist69 has joined #ponylang
_whitelogger has joined #ponylang
Xyliton has joined #ponylang
<Xyliton>
Hello! I tried to implement (at least a subset of) websockets using the available TCP connection stuff, but I only got to the "Switching Protocols" handshake. The server I'm trying to connect to is supposed to send a frame containing some heartbeat information directly after connecting, but I don't receive anything after the initial handshake through my `received` function.
<Xyliton>
Any idea what I might be doing wrong?
<SeanTAllen>
Without seeing your tcpconnection related code Xyliton, that's hard to know.
<SeanTAllen>
probably also difficult to evaluate without knowing the protocol
<SeanTAllen>
if you gist your TCPConnection related code, I might be able to look for errors not related to the protocol
<SeanTAllen>
From your basic description, it sounds like you are "doing it right"
<SeanTAllen>
I'd suggest using something to watch the packets on the wire to see if you are getting anything at all from the server after the heartbeat. that could help isolate where the issue is and help drive debugging.
<SeanTAllen>
it allows you to easily open a socket to listen for connections
<SeanTAllen>
if you have it installed, you can run "nc -l 127.0.0.1 5555"
<SeanTAllen>
and you will have a server listening on 127.0.0.1 port 5555
<SeanTAllen>
that will write all incoming data to standard out
<Xyliton>
hm... netcat isn't installed. Should I go with gnu-netcat?
<SeanTAllen>
i'm not sure what the arch package is
<Xyliton>
there's wscat too, which is specifically for websockets
<SeanTAllen>
o nice
<SeanTAllen>
so a tool like that to help verify you are getting what you expect
<Xyliton>
Okay, I'll try to use them. Thanks!
<SeanTAllen>
you're welcome. if you run into a Pony specific problem I can help with, you can usually get me here, if not, there's the mailing list.
<Xyliton>
nc doesn't return anything. wscat tells me that I'm connected though.
<SeanTAllen>
im not sure how wscat works, does it show the handshake?
<SeanTAllen>
if nc receives data, it should print it to standard out
<Xyliton>
nevermind, I had to specify the port with -p.
<Xyliton>
it prints out my handshake now
<SeanTAllen>
ah good
<Xyliton>
I'm sure that it's RFC compliant too
<SeanTAllen>
ok
<SeanTAllen>
next question then is... is the server you are connecting to send back what comes after the handshake...
<Xyliton>
after the handshake nothing happens. wscat is able to create a websocket connection though, and I'm able to send data from wscat to my program
<Xyliton>
So it probably is a problem with the websocket I'm trying to connect to
<Xyliton>
Now onto framing... I'm also trying to write a class which frames/"un-frames" data for me. But the RFC is somewhat "weird", because it requires me to write 7, 7+16 or 7+64 bits for the "data size", and I have no idea how to achieve that with Pony. I found the Writer class in "buffered", but it can only go down to writing bytes, not bits AFAIK
<Xyliton>
I wrote a small function which builds a byte from single bits, but that still makes it a lot harder for me after reaching the "data size" field because I will have to shift everything by one bit, which basically breaks all the write functions a Writer has, iirc
<SeanTAllen>
check out `expect` on TCPConnection
<SeanTAllen>
o
<SeanTAllen>
this is on the write side?
<SeanTAllen>
you probably have to write a class to handle that/do manually
Praetonus has quit [Ping timeout: 268 seconds]
Praetonus has joined #ponylang
<Xyliton>
I added a call to expect(0) to my `received` but nothing changed
<Xyliton>
Would writing FFI bindings for some existing ws lib be easier?
<Xyliton>
wait, nevermind. I somehow did some magic and now I receive what I expected
<Xyliton>
SeanTAllen: is there any builtin thing I can use to write data bit by bit?
<tokenrove>
oh, that makes me realize; a feature that would be really nice (wishlist) is bit syntax like erlang. there's an ocaml syntax extension that does it in a way that would be more congruent with pony's existing syntax.
<Xyliton>
Is it possible to "serialize" an Array so I can inspect it in my terminal?
<SeanTAllen>
Xyliton: no to the built in bit stuff
<SeanTAllen>
Re: serialization, you can turn an Array[u8] into a string
<SeanTAllen>
Check out the string class
<SeanTAllen>
Expect(0) is default case so that has no impact
<SeanTAllen>
tokenrove: RFC for that would be welcomed
<Xyliton>
btw, I managed to receive the expected data from the server. I had to specify some query string stuff in the headers
<tokenrove>
SeanTAllen: ok, will do (when I get some time)
<Xyliton>
It's just a simple thing which allows you to stuff single bits into an array. It automatically converts from that Array[U8] which holds the single bits into an Array[U8] full of bytes, filling the last byte with 0s if the bit amount is not divisble by 8
<staticassert>
Would this be a situation where you would 'recover' the iso?
<SeanTAllen>
so this is fun and complicated by the reverse
<SeanTAllen>
check out the change i did to done
<SeanTAllen>
Xyliton: did you want the result of done to be mutable or is immutable fine?
<SeanTAllen>
i worked under the assumption of "mutable"
<Xyliton>
once the frame built the payload, I'm never going to change it so either one would be fine
<SeanTAllen>
ok well
<SeanTAllen>
mutable it is then
<SeanTAllen>
back later. let me know if that example works for you.
<Xyliton>
yes, it's working as expected. Thanks <3
jemc has quit [Ping timeout: 240 seconds]
<obadz>
A unicode char is represented as a U32 ?
plietar has joined #ponylang
abbiya has joined #ponylang
abbiya has quit [Client Quit]
<SeanTAllen>
obadz: yes. you can check it all out in String.pony (note a string has no encoding, for that you want to look a StringRunes)
<obadz>
SeanTAllen: why is it called Runes?
chemist69 has quit [Ping timeout: 246 seconds]
chemist69 has joined #ponylang
<SeanTAllen>
i didn't name it
<SeanTAllen>
but one meaning of rune is "a letter of an ancient Germanic alphabet, related to the Roman alphabet."
<SeanTAllen>
i believe it would be an attempt at a name other than "character" which is overloaded with meaning thanks to the `char` type in C
<staticassert>
I think Go takes a similar approach
<staticassert>
and I like it
staticassert has quit [Quit: Page closed]
Matthias247 has joined #ponylang
<Xyliton>
Are there any tips on how I should design a (websocket) lib for Pony?
<Xyliton>
Should I do it the way the http client works?
<SeanTAllen>
I havent worked with the http client so, i can't comment on that
<SeanTAllen>
but, from the bit that i did look at it, the general pattern is follows is very much like how TCPConnection works and is a generally good place to start from when designing async pony code
<Xyliton>
So I could also build upon the TCPConnection "pattern"?
<Xyliton>
instead of trying to derive websockets from http
<SeanTAllen>
not saying that
<SeanTAllen>
just saying that its a good general pattern for async pony code
<SeanTAllen>
you'll see it in the process monitor as well
<SeanTAllen>
if you come up with a design and want someone to bounce it off of, feel free to email me
<Xyliton>
I'm just like... 2 days into pony so I have no idea what's good and/or bad.
<Xyliton>
Okay
<SeanTAllen>
that's alright.
<SeanTAllen>
the mailing list is good as well if you are comfortable with it. then others can see/join in the discussion
<SeanTAllen>
it takes a while to get a feel for it
<Xyliton>
I'll just try to write _something_. If I get it working I'll come back and ask here?
<Xyliton>
I never worked with mailing lists before
<SeanTAllen>
ive been writing pony every day for about 14 months now and there are still plenty of things i'm not sure of in terms of good/bad
<SeanTAllen>
Xyliton: sure. or you can email me directly, sometimes that can be much easier than IRC. your choice.
<Xyliton>
How do I use a buffered Reader for constructing a Frame? When using it in a constructor I have to wrap it inside a try block which errors saying that I didn't set the values needed
plietar has quit [Remote host closed the connection]
plietar has joined #ponylang
plietar has quit [Ping timeout: 264 seconds]
<obadz>
SeanTAllen / staticassert: hmm ok
chemist69 has quit [Ping timeout: 246 seconds]
chemist69 has joined #ponylang
<SeanTAllen>
Xyliton: can you gist your code?
<Xyliton>
https://github.com/TheFreakLord/pony-ws It's in a public git repo now. I opted for just parsing the frame in `received` right now, instead of using the parse function I have in the frame class
<Xyliton>
Now I'm trying to figure out how to implement fragmented frames
<Xyliton>
It's all some "proprietary" mess right now so I'm trying to standardize/generalize it as soon as possible
<Xyliton>
I thought about having a class which receives the tcp notifications and then forwards them to a "parent" object, which decides what to do with the data (wait for fragments, or handle the frame). When it collected a complete message it should forward the content of the frame to another object.
<Xyliton>
is that a viable method?
<Xyliton>
(I'll be offline for now. I hope the irc log will last long enough)
Xyliton has left #ponylang [#ponylang]
jemc has joined #ponylang
jemc has quit [Client Quit]
jemc has joined #ponylang
Praetonus has quit [Quit: Leaving]
staticassert has joined #ponylang
<staticassert>
hey where's that RFC on error handling? Wanted to comment on it but can't find it.
<staticassert>
it's on exceptions
jemc has quit [Ping timeout: 240 seconds]
<SeanTAllen>
staticassert: it's in the PRs. "Stateful Exceptions"