Advertisement
Guest User

Untitled

a guest
Jul 24th, 2018
2,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var username, password, worldid;
  2. username = "guest";
  3. password = "guest";
  4. worldid = "PWiD05QMRyb0I";
  5.  
  6. var cli, cfg, con;
  7.  
  8. PlayerIO.authenticate("everybody-edits-su9rn58o40itdbnw69plyw", "simpleUsers", { username: username, password: password }, {}, loginSuccess, fail("Authenticate"));
  9.  
  10. function loginSuccess(client) {
  11.     cli = client;
  12.     cli.bigDB.load("config", "config", configSuccess, fail("Config"));
  13. }
  14.  
  15. function configSuccess(config) {
  16.     cfg = config;
  17.     cli.multiplayer.createJoinRoom(worldid, "Everybodyedits" + cfg.version, true, null, null, connectSuccess, fail("Connect"));
  18. }
  19.  
  20. function connectSuccess(connection) {
  21.     con = connection;
  22.     con.send("init");
  23.     con.addMessageCallback("*", onMessage);
  24. }
  25.  
  26. function fail(location) {
  27.     return error => console.log("Location: " + location + ", Error: " + error.code + ", Message: " + error.message);
  28. }
  29.  
  30. function onMessage(msg) {
  31.     switch (msg.type) {
  32.         case "init":
  33.             con.send("init2");
  34.             break;
  35.         case "init2":
  36.             console.log("Success!");
  37.             break;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement