Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathProgram.cs
More file actions
Latest commit
60 lines (48 loc) · 2.08 KB
/
Copy pathProgram.cs
File metadata and controls
60 lines (48 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
usingVRChat.API.Client;
usingVRChat.API.Model;
usingVRChat.API.Realtime;
namespaceVRChat.API.Examples.WebSocket
{
publicclassProgram
{
publicstaticasyncTaskMain(string[]args)
{
stringusername=Environment.GetEnvironmentVariable("VRCHAT_USERNAME");
stringpassword=Environment.GetEnvironmentVariable("VRCHAT_PASSWORD");
stringtwoFactorSecret=Environment.GetEnvironmentVariable("VRCHAT_TWO_FACTOR_SECRET");
IVRChatvrchat=newVRChatClientBuilder()
.WithUsername(username)
.WithPassword(password)
.WithTwoFactorSecret(twoFactorSecret)
.WithApplication(name:"Example",version:"1.0.0",contact:"youremail.com")
.Build();
varcurrentUser=awaitvrchat.LoginAsync();
Console.WriteLine($"Logged in as {currentUser.DisplayName}!");
varauthToken=vrchat.GetCookies().FirstOrDefault(c =>c.Name=="auth")?.Value;
IVRChatRealtimerealtime=newVRChatRealtimeClientBuilder()
.WithAuthToken(authToken)
.WithApplication(name:"Example",version:"1.0.0",contact:"youremail.com")
.Build();
realtime.OnConnected+=(sender,e)=>
{
Console.WriteLine("Connected to VRChat Realtime WebSocket!");
};
realtime.OnFriendOnline+=(sender,e)=>
{
Console.WriteLine($"Friend {e.Message.User.DisplayName} is now online!");
};
realtime.OnFriendOffline+=(sender,e)=>
{
Console.WriteLine($"Friend {e.Message.UserId} is now offline!");
};
realtime.OnFriendLocation+=(sender,e)=>
{
Console.WriteLine($"Friend {e.Message.User.DisplayName} is now in {e.Message.Location}!");
};
awaitrealtime.ConnectAsync();
Console.ReadLine();
awaitrealtime.DisconnectAsync();
realtime.Dispose();
}
}
}