Created
March 20, 2017 20:33
-
-
Save MagnificentPako/3707759b6a19c88376d3492efa070c35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use "json" | |
use "net" | |
use "files" | |
use "net/ssl" | |
use "json" | |
class TestWSNotify is WebsocketNotify | |
let _env: Env | |
var _identified: Bool = false | |
new iso create(env': Env) => | |
_env = env' | |
fun received(conn: TCPConnection, data: String) => | |
_env.out.print(data) | |
if(not _identified) then | |
var wrapper: JsonDoc = JsonDoc | |
var dat: JsonObject = JsonObject | |
var main: JsonObject = JsonObject | |
var props: JsonObject = JsonObject | |
var shard: JsonArray = JsonArray | |
shard.data.push(I64(0)) | |
shard.data.push(I64(1)) | |
main.data("shard") = shard | |
props.data("$os") = "linux" | |
props.data("$browser") = "Pony" | |
props.data("$device") = "Pony" | |
props.data("$referrer") = "" | |
props.data("$referring_domain") = "" | |
main.data("properties") = props | |
main.data("token") = "" | |
main.data("compress") = false | |
main.data("large_threshold") = I64(250) | |
dat.data("d") = main | |
dat.data("op") = I64(2) | |
wrapper.data = dat | |
conn.write(wrapper.string()) | |
end | |
actor Main | |
new create(env: Env) => | |
let sslctx: (None | SSLContext) = try | |
recover SSLContext | |
.>set_client_verify(true) | |
.>set_authority(FilePath(env.root as AmbientAuth, "cacert.pem")) | |
end | |
end | |
try | |
let ctx = sslctx as SSLContext | |
let ssl = ctx.client() | |
TCPConnection(env.root as AmbientAuth, | |
SSLConnection(WebsocketHandler("gateway.discord.gg","/?v=6&encoding=json",TestWSNotify(env)), consume ssl), | |
"gateway.discord.gg", | |
"443") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment