// // ApiWorld // public void OnWorld(ApiWorld world) { if (InvokeRequired) { BeginInvoke(new MethodInvoker(() => { OnWorld(world); })); } else { m_WorldNames[world.id] = world.name; if (m_GPS.Remove(world.id)) { foreach (var pair in m_Friends) { var user = pair.Value; var L = LocationInfo.Parse(user.location); if (L != null && L.WorldId.Equals(world.id)) { var locationInfo = $"{world.name} {L.InstanceInfo}"; user.locationInfo = locationInfo; if (!string.IsNullOrEmpty(user.pastLocation)) { VRSEX.SetActivity(new ActivityInfo { Type = ActivityType.PlayerGPS, Text = DateTime.Now.ToString("HH:mm") + " " + user.displayName + " is " + locationInfo, Group = GetFriendsGroupIndex(user.id) }); } } } } } }
private static void Parse(string line) { try { if (line[34] == '[') { if (line[46] == ']') { var s = line.Substring(34); if (s.StartsWith("[RoomManager] Joining ")) { if (s.StartsWith("[RoomManager] Joining or Creating Room: ")) { s = line.Substring(74); if (!string.IsNullOrEmpty(m_Location)) { WorldName = s; var L = LocationInfo.Parse(m_Location); if (L != null) { AccessTag = L.InstanceInfo; s += " " + L.InstanceInfo; } else { AccessTag = string.Empty; } VRSEX.SetActivity(new ActivityInfo { Type = ActivityType.EnterWorld, Text = line.Substring(11, 5) + " " + s, Tag = m_Location }); m_InRoom.Clear(); m_Location = string.Empty; } } else { m_Location = line.Substring(56); } } } else if (line[49] == ']') { var s = line.Substring(34); if (s.StartsWith("[NetworkManager] OnPlayerLeft ")) { s = line.Substring(64); if (m_InRoom.TryGetValue(s, out string id)) { VRSEX.SetActivity(new ActivityInfo { Type = ActivityType.PlayerLeft, Text = line.Substring(11, 5) + " " + s + " has left", Tag = s, Group = MainForm.Instance.GetFriendsGroupIndex(id) }); m_InRoom.Remove(s); } } } else if (line[52] == ']') { var s = line.Substring(34); if (s.StartsWith("[VRCFlowManagerVRC] User Authenticated: ")) { m_CurrentUser = line.Substring(74); } } } else if (line[34] == 'R') { var s = line.Substring(34); if (s.StartsWith("Received API user ")) { m_UserID = line.Substring(52); } } else if (line[34] == 'S') { var s = line.Substring(34); if (s.StartsWith("Switching ")) { var i = s.IndexOf(" to avatar "); if (i > 10) { s = s.Substring(10, i - 10); if (!string.IsNullOrEmpty(m_UserID)) { if (!m_InRoom.ContainsKey(s)) { VRSEX.SetActivity(new ActivityInfo { Type = ActivityType.PlayerJoined, Text = line.Substring(11, 5) + " " + s + " has joined", Tag = s, Group = MainForm.Instance.GetFriendsGroupIndex(m_UserID) }); } m_InRoom[s] = m_UserID; m_UserID = string.Empty; } } } } } catch { } }
public void OnFriends(List <ApiUser> users) { if (InvokeRequired) { BeginInvoke(new MethodInvoker(() => { OnFriends(users); })); } else { foreach (var user in users) { if (m_Friends.TryGetValue(user.id, out ApiUser _user)) { user.pastLocation = _user.location; } m_Friends[user.id] = user; var notify = true; var locationInfo = user.location; LocationInfo L = LocationInfo.Parse(user.location); if (L != null) { if (m_WorldNames.TryGetValue(L.WorldId, out string worldName)) { locationInfo = $"{worldName} {L.InstanceInfo}"; } else { notify = false; if (m_GPS.Add(L.WorldId)) { ApiWorld.Fetch(L.WorldId); } } } user.locationInfo = locationInfo; if (!string.IsNullOrEmpty(user.pastLocation) && !string.Equals(user.pastLocation, user.location)) { if ("offline".Equals(user.location, StringComparison.OrdinalIgnoreCase)) { VRSEX.SetActivity(new ActivityInfo { Type = ActivityType.PlayerLogout, Text = DateTime.Now.ToString("HH:mm") + " " + user.displayName + " has logged out", Group = GetFriendsGroupIndex(user.id) }); } else { if ("offline".Equals(user.pastLocation, StringComparison.OrdinalIgnoreCase)) { VRSEX.SetActivity(new ActivityInfo { Type = ActivityType.PlayerLogin, Text = DateTime.Now.ToString("HH:mm") + " " + user.displayName + " has logged in", Group = GetFriendsGroupIndex(user.id) }); if ("private".Equals(user.location, StringComparison.OrdinalIgnoreCase)) { continue; } } if (notify) { VRSEX.SetActivity(new ActivityInfo { Type = ActivityType.PlayerGPS, Text = DateTime.Now.ToString("HH:mm") + " " + user.displayName + " is " + locationInfo, Group = GetFriendsGroupIndex(user.id) }); } } } } } }
public static LocationInfo Parse(string idWithTags, bool strict = true) { // offline // private // local:0000000000 // Public wrld_785bee79-b83b-449c-a3d9-f1c5a29bcd3d:12502 // Friends+ wrld_785bee79-b83b-449c-a3d9-f1c5a29bcd3d:12502~hidden(usr_4f76a584-9d4b-46f6-8209-8305eb683661)~nonce(79985ba6-8804-49dd-8c8a-c86fe817caca) // Friends wrld_785bee79-b83b-449c-a3d9-f1c5a29bcd3d:12502~friends(usr_4f76a584-9d4b-46f6-8209-8305eb683661)~nonce(13374166-629e-4ac5-afe9-29637719d78c) // Invite+ wrld_785bee79-b83b-449c-a3d9-f1c5a29bcd3d:12502~private(usr_4f76a584-9d4b-46f6-8209-8305eb683661)~nonce(6d9b02ca-f32c-4360-b8ac-9996bf12fd74)~canRequestInvite // Invite wrld_785bee79-b83b-449c-a3d9-f1c5a29bcd3d:12502~private(usr_4f76a584-9d4b-46f6-8209-8305eb683661)~nonce(5db0f688-4211-428b-83c5-91533e0a5d5d) // wrld_가 아니라 wld_인 것들도 있고 예전 맵들의 경우 아예 o_나 b_인것들도 있음; 그냥 uuid형태인 것들도 있고 개판임 var tags = idWithTags.Split('~'); var a = tags[0].Split(new char[] { ':' }, 2); if (!string.IsNullOrEmpty(a[0])) { if (a.Length == 2) { if (!string.IsNullOrEmpty(a[1]) && !"local".Equals(a[0])) { var L = new LocationInfo { WorldId = a[0] }; var type = "public"; if (tags.Length > 1) { var tag = "~" + string.Join("~", tags, 1, tags.Length - 1); if (tag.Contains("~private(")) { if (tag.Contains("~canRequestInvite")) { type = "invite+"; // Invite Plus } else { type = "invite"; // Invite Only } } else if (tag.Contains("~friends(")) { type = "friends"; // Friends Only } else if (tag.Contains("~hidden(")) { type = "friends+"; // Friends of Guests } L.InstanceId = a[1] + tag; } else { L.InstanceId = a[1]; } L.InstanceInfo = $"#{a[1]} {type}"; return(L); } } else if (!strict && !("offline".Equals(a[0]) || "private".Equals(a[0]))) { return(new LocationInfo() { WorldId = a[0] }); } } return(null); }