Exemplo n.º 1
0
        public Client(INativeClient nativeClient)
        {
            MainThread          = Thread.CurrentThread;
            ForegroundStopwatch = new Stopwatch();
            BackgroundStopwatch = new Stopwatch();
            NativeClient        = nativeClient;
            User = new User {
                Id = SystemInfo.deviceUniqueIdentifier
            };
            Middleware      = new List <Middleware>();
            Metadata        = new Metadata(nativeClient);
            UniqueCounter   = new UniqueLogThrottle(Configuration);
            LogTypeCounter  = new MaximumLogTypeCounter(Configuration);
            SessionTracking = new SessionTracker(this);
            UnityMetadata.InitDefaultMetadata();
            Device.InitUnityVersion();
            NativeClient.SetMetadata(UnityMetadataKey, UnityMetadata.ForNativeClient());

            NativeClient.PopulateUser(User);

            SceneManager.sceneLoaded += SceneLoaded;
            Application.logMessageReceivedThreaded += MultiThreadedNotify;
            Application.logMessageReceived         += Notify;
            User.PropertyChanged += (obj, args) => { NativeClient.SetUser(User); };
            TimingTrackerObject   = new GameObject("Bugsnag app lifecycle tracker");
            TimingTrackerObject.AddComponent <TimingTrackerBehaviour>();
            // Run initial session check in next frame to allow potential configuration
            // changes to be completed first.
            try {
                var asyncHandler = MainThreadDispatchBehaviour.Instance();
                asyncHandler.Enqueue(RunInitialSessionCheck());
            } catch (System.Exception ex) {
                // Async behavior is not available in a test environment
            }
        }
 void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
 }
Exemplo n.º 3
0
 void SerializeAndDeliverPayload(IPayload payload)
 {
     using (var stream = new MemoryStream())
         using (var reader = new StreamReader(stream))
             using (var writer = new StreamWriter(stream, new UTF8Encoding(false))
             {
                 AutoFlush = false
             })
             {
                 BugsnagUnity.SimpleJson.SerializeObject(payload, writer);
                 writer.Flush();
                 stream.Position = 0;
                 var body = Encoding.UTF8.GetBytes(reader.ReadToEnd());
                 MainThreadDispatchBehaviour.Instance().Enqueue(PushToServer(payload, body));
             }
 }
 void OnDestroy()
 {
     _instance = null;
 }