Beispiel #1
0
        public void ClientSync(bool ConnectionFailureTimeout = false)
        {
            ThrowIfNotSupported();
            string url = "/_matrix/client/r0/sync?timeout=" + SyncTimeout;

            if (!String.IsNullOrEmpty(syncToken))
            {
                url += "&since=" + syncToken;
            }
            MatrixRequestError error = mbackend.Get(url, true, out var response);

            if (error.IsOk)
            {
                try {
                    MatrixSync sync = JsonConvert.DeserializeObject <MatrixSync> (response.ToString(), event_converter);
                    ProcessSync(sync);
                    IsConnected = true;
                } catch (Exception e) {
                    Console.WriteLine(e.InnerException);
                    throw new MatrixException("Could not decode sync", e);
                }
            }
            else if (ConnectionFailureTimeout)
            {
                IsConnected = false;
                Console.Error.WriteLine("Couldn't reach the matrix home server during a sync.");
                Console.Error.WriteLine(error.ToString());
                Thread.Sleep(BadSyncTimeout);
            }
            if (RunningInitialSync)
            {
                RunningInitialSync = false;
            }
        }
Beispiel #2
0
    private IEnumerator WaitForNetId(MatrixSync matrixSync)
    {
        while (matrixSync.netId == 0)
        {
            yield return(WaitFor.EndOfFrame);
        }

        RunOreGenerator();
    }
Beispiel #3
0
 private void ProcessSync(MatrixSync syncData)
 {
     syncToken = syncData.next_batch;
     //Grab data from rooms the user has joined.
     foreach (KeyValuePair <string, MatrixEventRoomJoined> room in syncData.rooms.join)
     {
         SyncJoinEvent?.Invoke(room.Key, room.Value);
     }
     foreach (KeyValuePair <string, MatrixEventRoomInvited> room in syncData.rooms.invite)
     {
         SyncInviteEvent?.Invoke(room.Key, room.Value);
     }
 }
        public void BackUpSetMatrixSync()
        {
            if (MatrixSync != null)
            {
                return;
            }

            foreach (Transform child in transform)
            {
                if (child.TryGetComponent <MatrixSync>(out var matrixSync) && matrixSync != null)
                {
                    MatrixSync = matrixSync;
                    return;
                }
            }

            Logger.LogError($"Failed to find matrix sync for {gameObject.name}");
        }