Ejemplo n.º 1
0
        // This method is called from the connection handlers (DriveConnection or DriveConnectionEditor).
        public static void ProcessResponse(string response, float time)
        {
            DataContainer dataContainer;

            try
            {
                dataContainer = JsonUtility.FromJson <DataContainer>(response);
            }
            catch (Exception)
            {
                HandleError("Undefined server response: \n" + response, time);
                return;
            }

            if (dataContainer.result == "ERROR")
            {
                HandleError(dataContainer.msg, time);
                return;
            }

            if (string.IsNullOrEmpty(dataContainer.result) || dataContainer.result != "ERROR" && dataContainer.result != "OK")
            {
                HandleError("Undefined server response: \n" + response, time);
                return;
            }

            if (dataContainer.QueryType == QueryType.login)
            {
                _sessionContext = JsonUtility.FromJson <SessionContextData>(dataContainer.payload);
                _sessionContext.sessionStart      = DateTime.Now;
                _connectionData.useSessionContext = true;
            }

            if (dataContainer.QueryType == QueryType.logout)
            {
                _sessionContext = null;
            }

            if (responseCallback != null)
            {
                responseCallback(dataContainer);
            }
        }
 internal void SetDefaults(SessionContextData source)
 {
     this.tags.InitializeTagValue(ContextTagKeys.Keys.SessionId, source.Id);
     this.tags.InitializeTagValue(ContextTagKeys.Keys.SessionIsFirst, source.IsFirst);
     this.tags.InitializeTagValue(ContextTagKeys.Keys.SessionIsNew, source.IsNewSession);
 }
 internal void SetDefaults(SessionContextData source)
 {
     this.tags.InitializeTagValue(ContextTagKeys.Keys.SessionId, source.Id);
     this.tags.InitializeTagValue(ContextTagKeys.Keys.SessionIsFirst, source.IsFirst);
     this.tags.InitializeTagValue(ContextTagKeys.Keys.SessionIsNew, source.IsNewSession);
 }