private void _handlePlayerPreferences(IMessageBase messageBase) { PreferencesMessage preferences = (PreferencesMessage)messageBase; Logger.Debug("Received new player preferences from P" + preferences.UserId); if (preferences == null) { Logger.Warn("Received invalid message type " + messageBase.GetType() + ". Expected " + typeof(PreferencesMessage)); return; } if (preferences.UserId < 0) { Logger.Warn("Received invalid player id " + preferences.UserId); return; } if (!PlayerData.Instance.TryGetEntry(preferences.UserId, out PlayerDataEntry entry)) { Logger.Warn("Received unregistered player id " + preferences.UserId); return; } entry.UpdatePreferences(preferences.preferences); SendToFrontend(new FrontendPayload(preferences)); MetricLogger.Log(preferences.UserId + " reregistered as " + preferences.preferences.SceneName); }
protected void _handleTimeMessage(IMessageBase baseMessage) { //Debug.Log("Received time message"); if (!(baseMessage is TimeMessage)) { Logger.Warn("Received the incorrect message type " + baseMessage.GetType() + ". " + "Excepted " + typeof(TimeMessage)); return; } TimeMessage message = (TimeMessage)baseMessage; SendUnreliable(message); //Logger.Info("Received time message: " + message.turn + " " + message.millis + " " + message.turnMillis); #if BACKEND double timeBeforeSync = VirtualSpaceTime.CurrentTimeInMillis; VirtualSpaceTime.Update(message.Millis, message.TripTime); double timeAfterSync = VirtualSpaceTime.CurrentTimeInMillis; double timeOffset = Math.Abs(timeAfterSync - timeBeforeSync); if (timeOffset > 20) { Logger.Warn($"{message.UserId}: Time offset was {Math.Abs(timeOffset)}"); } #elif UNITY LastTimeMessage = message; #endif //Debug.Log("Handled time message"); }
public static string GetTopicName(this IMessageBase message) { return((Attribute.GetCustomAttribute(message.GetType(), typeof(AWSSNSMapping)) as AWSSNSMapping).TopicName); }