예제 #1
0
        public VRChatApi(string username, string password)
        {
            // initialize endpoint classes
            RemoteConfig = new RemoteConfig();
            UserApi      = new UserApi(username, password);
            FriendsApi   = new FriendsApi();
            WorldApi     = new WorldApi();

            // initialize http client
            // TODO: use the auth cookie
            if (Global.HttpClient == null)
            {
                Global.HttpClient             = new HttpClient();
                Global.HttpClient.BaseAddress = new Uri("https://api.vrchat.cloud/api/1/");
            }

            string authEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{UserApi.Username}:{UserApi.Password}"));

            var header = Global.HttpClient.DefaultRequestHeaders;

            if (header.Contains("Authorization"))
            {
                header.Remove("Authorization");
            }
            header.Add("Authorization", $"Basic {authEncoded}");
        }
예제 #2
0
        public void CanHandleValidListRecentWorldsResponse()
        {
            MockHttpMessageHandler.SetResponse(new JArray(
                                                   new JObject(
                                                       new JProperty("id", "some world id"),
                                                       new JProperty("name", "some world name"),
                                                       new JProperty("authorName", "some author name"),
                                                       new JProperty("totalLikes", 420),
                                                       new JProperty("totalVisits", 1337),
                                                       new JProperty("imageUrl", "https://unit.test/imageUrl.jpg"),
                                                       new JProperty("thumbnailImageUrl", "https://unit.test/thumbnailImageUrl.jpg"),
                                                       new JProperty("isSecure", false),
                                                       new JProperty("releaseStatus", "public"),
                                                       new JProperty("organization", "some organization"),
                                                       new JProperty("occupants", 4))));

            var api    = new WorldApi();
            var result = api.Search(endpoint: WorldGroups.Recent).Result;

            result.Should().HaveCount(1);
            result[0].id.Should().Be("some world id");
            result[0].name.Should().Be("some world name");
            result[0].authorName.Should().Be("some author name");
            result[0].totalLikes.Should().Be(420);
            result[0].totalVisits.Should().Be(1337);
            result[0].imageUrl.Should().Be("https://unit.test/imageUrl.jpg");
            result[0].thumbnailImageUrl.Should().Be("https://unit.test/thumbnailImageUrl.jpg");
            result[0].isSecure.Should().BeFalse();
            result[0].releaseStatus.Should().Be(ReleaseStatus.Public);
            result[0].organization.Should().Be("some organization");
            result[0].occupants.Should().Be(4);
        }
예제 #3
0
        public VRChatApi(string username, string password)
        {
            Logger.Trace(() => $"Entering {nameof(VRChatApi)} constructor");
            Logger.Debug(() => $"Using username {username}");

            // initialize endpoint classes
            RemoteConfig   = new RemoteConfig();
            UserApi        = new UserApi(username, password);
            FriendsApi     = new FriendsApi();
            WorldApi       = new WorldApi();
            ModerationsApi = new ModerationsApi();
            AvatarApi      = new AvatarApi();

            // initialize http client
            // TODO: use the auth cookie
            if (Global.HttpClient == null)
            {
                Logger.Trace(() => $"Instantiating {nameof(HttpClient)}");
                Global.HttpClient             = new HttpClient();
                Global.HttpClient.BaseAddress = new Uri("https://api.vrchat.cloud/api/1/");
                Logger.Info(() => $"VRChat API base address set to {Global.HttpClient.BaseAddress}");
            }

            string authEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{UserApi.Username}:{UserApi.Password}"));

            var header = Global.HttpClient.DefaultRequestHeaders;

            if (header.Contains("Authorization"))
            {
                Logger.Debug(() => "Removing existing Authorization header");
                header.Remove("Authorization");
            }
            header.Add("Authorization", $"Basic {authEncoded}");
            Logger.Trace(() => $"Added new Authorization header");
        }
예제 #4
0
        public void CanHandleInternalServerErrorHttpStatusGetWorldByIdResponse()
        {
            MockHttpMessageHandler.SetResponse(string.Empty, HttpStatusCode.InternalServerError);
            var api    = new WorldApi();
            var result = api.Get("some world id").Result;

            result.Should().BeNull();
        }
예제 #5
0
        public void CanHandleInternalServerErrorHttpStatusListWorldsResponse()
        {
            MockHttpMessageHandler.SetResponse(string.Empty, HttpStatusCode.InternalServerError);
            var api    = new WorldApi();
            var result = api.Search().Result;

            result.Should().BeNull();
        }
예제 #6
0
    public void Initialize(WorldApi worldApi)
    {
        // orbit around the center of generated world
        Vector3 center = new Vector3(worldApi.GetWidth() * 0.5f, worldApi.GetHeight() * 0.5f, worldApi.GetDepth() * 0.5f);

        transform.parent.Translate(center);

        // zoom out from the world
        _distance += worldApi.GetDepth() * 0.5f;
    }
예제 #7
0
        public void CanHandleValidWorldMetadataResponse()
        {
            MockHttpMessageHandler.SetResponse(new JObject(
                                                   new JProperty("id", "some world id"),
                                                   new JProperty("metadata", new JObject())));

            var api    = new WorldApi();
            var result = api.GetMetadata("some world id").Result;

            result.id.Should().Be("some world id");
            result.metadata.Should().BeEmpty();
        }
    public void Initialize()
    {
        _worldApi = GetComponent <WorldApi>();

        _borderedChunk = new NativeArray <Voxel>(Chunk.kTotalVoxelsInBordered, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);

        _lastIsoLevel = IsoLevel;

        InitializeCpuRendering();

        if (GpuFluidRendering)
        {
            InitializeGpuRendering();
        }
    }
예제 #9
0
 private void Start()
 {
     WorldApi.LoadWorld();
 }
예제 #10
0
        public void CanHandleValidWorldInstanceResponse()
        {
            MockHttpMessageHandler.SetResponse(new JObject(
                                                   new JProperty("id", "some instance id"),
                                                   new JProperty("private", new JArray(
                                                                     new JObject(
                                                                         new JProperty("id", "some private user id"),
                                                                         new JProperty("username", "some private username"),
                                                                         new JProperty("displayName", "some private display name"),
                                                                         new JProperty("currentAvatarImageUrl", "https://unit.test/privateAvatarImageUrl.jpg"),
                                                                         new JProperty("currentAvatarThumbnailImageUrl", "https://unit.test/privateAvatarThumbnailImageUrl.jpg"),
                                                                         new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                                         new JProperty("developerType", "some private developer type"),
                                                                         new JProperty("status", "some private status"),
                                                                         new JProperty("statusDescription", "some private status description"),
                                                                         new JProperty("networkSessionId", "some private network session id")))),
                                                   new JProperty("friends", new JArray(
                                                                     new JObject(
                                                                         new JProperty("id", "some friend user id"),
                                                                         new JProperty("username", "some friend username"),
                                                                         new JProperty("displayName", "some friend display name"),
                                                                         new JProperty("currentAvatarImageUrl", "https://unit.test/friendAvatarImageUrl.jpg"),
                                                                         new JProperty("currentAvatarThumbnailImageUrl", "https://unit.test/friendAvatarThumbnailImageUrl.jpg"),
                                                                         new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                                         new JProperty("developerType", "some friend developer type"),
                                                                         new JProperty("status", "some friend status"),
                                                                         new JProperty("statusDescription", "some friend status description"),
                                                                         new JProperty("networkSessionId", "some friend network session id")))),
                                                   new JProperty("users", new JArray(
                                                                     new JObject(
                                                                         new JProperty("id", "some user id"),
                                                                         new JProperty("username", "some username"),
                                                                         new JProperty("displayName", "some display name"),
                                                                         new JProperty("currentAvatarImageUrl", "https://unit.test/currentAvatarImageUrl.jpg"),
                                                                         new JProperty("currentAvatarThumbnailImageUrl", "https://unit.test/currentAvatarThumbnailImageUrl.jpg"),
                                                                         new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                                         new JProperty("developerType", "some developer type"),
                                                                         new JProperty("status", "some status"),
                                                                         new JProperty("statusDescription", "some status description"),
                                                                         new JProperty("networkSessionId", "some network session id")))),
                                                   new JProperty("name", "some name")));

            var api    = new WorldApi();
            var result = api.GetInstance("some world id", "some instance id").Result;

            result.id.Should().Be("some instance id");
            result.privateUsers.Should().HaveCount(1);
            result.privateUsers[0].id.Should().Be("some private user id");
            result.privateUsers[0].username.Should().Be("some private username");
            result.privateUsers[0].displayName.Should().Be("some private display name");
            result.privateUsers[0].currentAvatarImageUrl.Should().Be("https://unit.test/privateAvatarImageUrl.jpg");
            result.privateUsers[0].currentAvatarThumbnailImageUrl.Should().Be("https://unit.test/privateAvatarThumbnailImageUrl.jpg");
            result.privateUsers[0].tags.Should().HaveCount(2);
            result.privateUsers[0].tags[0].Should().Be("tag 1");
            result.privateUsers[0].tags[1].Should().Be("tag 2");
            result.privateUsers[0].developerType.Should().Be("some private developer type");
            result.privateUsers[0].status.Should().Be("some private status");
            result.privateUsers[0].statusDescription.Should().Be("some private status description");
            result.privateUsers[0].networkSessionId.Should().Be("some private network session id");
            result.friends.Should().HaveCount(1);
            result.friends[0].id.Should().Be("some friend user id");
            result.friends[0].username.Should().Be("some friend username");
            result.friends[0].displayName.Should().Be("some friend display name");
            result.friends[0].currentAvatarImageUrl.Should().Be("https://unit.test/friendAvatarImageUrl.jpg");
            result.friends[0].currentAvatarThumbnailImageUrl.Should().Be("https://unit.test/friendAvatarThumbnailImageUrl.jpg");
            result.friends[0].tags.Should().HaveCount(2);
            result.friends[0].tags[0].Should().Be("tag 1");
            result.friends[0].tags[1].Should().Be("tag 2");
            result.friends[0].developerType.Should().Be("some friend developer type");
            result.friends[0].status.Should().Be("some friend status");
            result.friends[0].statusDescription.Should().Be("some friend status description");
            result.friends[0].networkSessionId.Should().Be("some friend network session id");
            result.users.Should().HaveCount(1);
            result.users[0].id.Should().Be("some user id");
            result.users[0].username.Should().Be("some username");
            result.users[0].displayName.Should().Be("some display name");
            result.users[0].currentAvatarImageUrl.Should().Be("https://unit.test/currentAvatarImageUrl.jpg");
            result.users[0].currentAvatarThumbnailImageUrl.Should().Be("https://unit.test/currentAvatarThumbnailImageUrl.jpg");
            result.users[0].tags.Should().HaveCount(2);
            result.users[0].tags[0].Should().Be("tag 1");
            result.users[0].tags[1].Should().Be("tag 2");
            result.users[0].developerType.Should().Be("some developer type");
            result.users[0].status.Should().Be("some status");
            result.users[0].statusDescription.Should().Be("some status description");
            result.users[0].networkSessionId.Should().Be("some network session id");
            result.name.Should().Be("some name");
        }
예제 #11
0
        public void CanHandleValidGetWorldByIdResponse()
        {
            MockHttpMessageHandler.SetResponse(new JObject(
                                                   new JProperty("id", "some world id"),
                                                   new JProperty("name", "some world name"),
                                                   new JProperty("description", "some world description"),
                                                   new JProperty("featured", false),
                                                   new JProperty("authorId", "some author id"),
                                                   new JProperty("authorName", "some author name"),
                                                   new JProperty("totalLikes", 420),
                                                   new JProperty("totalVisits", 1337),
                                                   new JProperty("capacity", (short)42),
                                                   new JProperty("tags", new JArray("tag 1", "tag 2")),
                                                   new JProperty("releaseStatus", "public"),
                                                   new JProperty("imageUrl", "https://unit.test/imageUrl.jpg"),
                                                   new JProperty("thumbnailImageUrl", "https://unit.test/thumbnailImageUrl.jpg"),
                                                   new JProperty("assetUrl", "https://unit.test/assetUrl.asset"),
                                                   new JProperty("pluginUrl", "https://unit.test/pluginUrl.plugin"),
                                                   new JProperty("unityPackageUrl", "https://unit.test/unityPackageUrl.unityPackage"),
                                                   new JProperty("namespace", "some namespace presumably"),
                                                   new JProperty("unityPackageUpdated", false),
                                                   new JProperty("unityPackages", new JArray(
                                                                     new JObject(
                                                                         new JProperty("id", "some unity package id"),
                                                                         new JProperty("assetUrl", "https://unit.test/1/assetUrl.asset"),
                                                                         new JProperty("pluginUrl", "https://unit.test/1/pluginUrl.plugin"),
                                                                         new JProperty("unityVersion", "7"),
                                                                         new JProperty("unitySortNumber", 9001),
                                                                         new JProperty("assetVersion", 1),
                                                                         new JProperty("platform", "some platform"),
                                                                         new JProperty("created_at", "some date")))),
                                                   new JProperty("isSecure", false),
                                                   new JProperty("isLockdown", false),
                                                   new JProperty("version", 2),
                                                   new JProperty("organization", "some organization"),
                                                   new JProperty("instances", new List <JArray> {
                new JArray("some instance id", 2)
            }),
                                                   new JProperty("occupants", 4)));

            var api    = new WorldApi();
            var result = api.Get("some world id").Result;

            result.id.Should().Be("some world id");
            result.name.Should().Be("some world name");
            result.description.Should().Be("some world description");
            result.featured.Should().BeFalse();
            result.authorId.Should().Be("some author id");
            result.authorName.Should().Be("some author name");
            result.totalLikes.Should().Be(420);
            result.totalVisits.Should().Be(1337);
            result.capacity.Should().Be(42);
            result.tags.Should().HaveCount(2);
            result.tags[0].Should().Be("tag 1");
            result.tags[1].Should().Be("tag 2");
            result.releaseStatus.Should().Be(ReleaseStatus.Public);
            result.imageUrl.Should().Be("https://unit.test/imageUrl.jpg");
            result.thumbnailImageUrl.Should().Be("https://unit.test/thumbnailImageUrl.jpg");
            result.assetUrl.Should().Be("https://unit.test/assetUrl.asset");
            result.pluginUrl.Should().Be("https://unit.test/pluginUrl.plugin");
            result.unityPackageUrl.Should().Be("https://unit.test/unityPackageUrl.unityPackage");
            result.nameSpace.Should().Be("some namespace presumably");
            result.unityPackageUpdated.Should().BeFalse();
            result.unityPackages.Should().HaveCount(1);
            result.unityPackages[0].id.Should().Be("some unity package id");
            result.unityPackages[0].assetUrl.Should().Be("https://unit.test/1/assetUrl.asset");
            result.unityPackages[0].pluginUrl.Should().Be("https://unit.test/1/pluginUrl.plugin");
            result.unityPackages[0].unityVersion.Should().Be("7");
            result.unityPackages[0].unitySortNumber.Should().Be(9001);
            result.unityPackages[0].assetVersion.Should().Be(1);
            result.unityPackages[0].platform.Should().Be("some platform");
            result.unityPackages[0].createdTime.Should().Be("some date");
            result.isSecure.Should().BeFalse();
            result.isLockdown.Should().BeFalse();
            result.version.Should().Be(2);
            result.organization.Should().Be("some organization");
            result.instances.Should().HaveCount(1);
            result.instances[0].id.Should().Be("some instance id");
            result.instances[0].occupants.Should().Be(2);
            result.occupants.Should().Be(4);
        }
예제 #12
0
 public void Initialize()
 {
     _worldApi       = GetComponent <WorldApi>();
     _fluidProcessor = GetComponent <FluidProcessor>();
 }
예제 #13
0
 public void Init()
 {
     instance = new WorldApi();
 }
예제 #14
0
        public ViewResult World()
        {
            WorldApi worldApi = new WorldApi("Worlds");

            return(View(worldApi));
        }