started at . submit by
oh, happy day! sunshine returns to cg valley. now please connect to this websocket. submissions may be written in any language.
WebSocket is a communications protocol. I'm not going to detail the whole thing here, but I can explain the handshake. a WebSocket connection starts as a special kind of HTTP ≥1.1 request with at minimum the following headers, and no body:
Connection: upgrade
Upgrade: websocket
Host: hostname.com
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: Some16ByteBase64NonceA==
the server responds, likewise with no body:
Connection: upgrade
Upgrade: websocket
Sec-WebSocket-Accept: 9WOgMTgkwOaUOmn9o5tTgvhZ2SA=
for those who missed it, Sec-WebSocket-Accept in the server's response is equal to base64(sha1(Sec-WebSocket-Key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))
, where +
denotes string concatenation.
at this point, the opening handshake is complete and the interlocutors may now begin sending messages to each other.
your challenge is to connect to the WebSocket server running at wss://codeguessing.gay/73/ws
. as this challenge only requires performing a fixed task, no API is necessary.
incidentally, this server sends and receives text messages with the following interface:
{"reason": "connect", "name": x}
: someone named x
joined.{"reason": "disconnect", "name": x}
: x
left.{"reason": "message", "name": x, "content": t}
: x
sent a message with content t
.{"content": t}
: send a message with content t
.6 entries have been received so far.