// // 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) }); } } } } } }
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) }); } } } } } }
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 { } }