public void SaveObject(NCMBObject obj)
    {
        if (_created)
        {
            Debug.LogWarning("you can only one object save");
            return;
        }

        if (_actNow)
        {
            Debug.LogWarning("now saving action:you cant additional save");
            return;
        }
        _actNow = true;
        obj.SaveAsync((NCMBException e) =>
        {
            if (e != null)
            {
            }
            else
            {
                _created  = true;
                _objectID = obj.ObjectId;

                var json         = GetJson_connectState(obj);
                _myNCMBState     = JsonConverter.FromJson <NCMBStateData>(json).myNCMBstate;
                _serverNCMBState = _myNCMBState;

                Debug.Log("save end");
            }
        });
    }
Пример #2
0
    void SendSDP(RTCSessionDescription session, NCMBStateData.MyNCMBstate state)
    {
        bool isoffer    = (session.type == RTCSdpType.Offer);
        var  type       = (isoffer) ? RTCSendData.DATATYPE.OFFERE : RTCSendData.DATATYPE.ANSWER;
        var  data       = new RTCSendData(type, session.sdp);
        var  json       = JsonConverter.ToJson(data);
        var  json_state = JsonConverter.ToJson(new NCMBStateData(state));

        _signalingNCMB.FetchObject((NCMBObject obj) => {
            var saveobj = NCMB_RTC.SetJson_SDPData(obj, isoffer, json);
            saveobj     = NCMB_RTC.SetJson_connectState(saveobj, json_state);
            _signalingNCMB.UpdateObject(saveobj);
        });
    }
Пример #3
0
 private void Update()
 {
     WaitFlagUpdate();
     CheckRTCConnectUpdate();
     //stateが変更されるまでにラグがあるので変更中に処理をしないようにしたい
     //一度処理を行ったstateには処理をしないことで対応 場当たり的な感じあるので微妙
     if (_signalingNCMB._ServerNCMBState == _lastActState)
     {
         return;
     }
     _lastActState = _signalingNCMB._ServerNCMBState;
     if (_myRTCType == RTCTYPE.OFFER)
     {
         ConnectAction_offer();
     }
     else if (_myRTCType == RTCTYPE.ANSWER)
     {
         ConnectAction_answer();
     }
 }
 public void UpdateObject(NCMBObject obj)
 {
     if (_objectID != obj.ObjectId)
     {
         Debug.LogWarning($"objectid is uncorrect:{_objectID},{obj.ObjectId}");
         return;
     }
     obj.SaveAsync((NCMBException e) =>
     {
         if (e != null)
         {
         }
         else
         {
             var json         = GetJson_connectState(obj);
             _myNCMBState     = JsonConverter.FromJson <NCMBStateData>(json).myNCMBstate;
             _serverNCMBState = _myNCMBState;
             Debug.Log("update end");
         }
     });
 }
    public void FetchObject(Action <NCMBObject> act)
    {
        if (!_created)
        {
            return;
        }
        var obj = new NCMBObject("NCMB_RTC");

        obj.ObjectId = _objectID;
        obj.FetchAsync((NCMBException e) => {
            if (e != null)
            {
            }
            else
            {
                var json         = GetJson_connectState(obj);
                _serverNCMBState = JsonConverter.FromJson <NCMBStateData>(json).myNCMBstate;
                act?.Invoke(obj);
            }
        });
    }