Пример #1
0
        public static PeerConnection.PeerConnectionState ToNative(this PeerConnectionState self)
        {
            switch (self)
            {
            case PeerConnectionState.New:
                return(PeerConnection.PeerConnectionState.New);

            case PeerConnectionState.Connecting:
                return(PeerConnection.PeerConnectionState.Connecting);

            case PeerConnectionState.Connected:
                return(PeerConnection.PeerConnectionState.Connected);

            case PeerConnectionState.Disconnected:
                return(PeerConnection.PeerConnectionState.Disconnected);

            case PeerConnectionState.Failed:
                return(PeerConnection.PeerConnectionState.Failed);

            case PeerConnectionState.Closed:
                return(PeerConnection.PeerConnectionState.Closed);

            default:
                throw new ArgumentOutOfRangeException(nameof(self), self, null);
            }
        }
Пример #2
0
 public void Disconnect()
 {
     if (m_remoteID != 0)
     {
         Net.Close(m_remoteID);
         m_remoteID = 0;
         m_state    = PeerConnectionState.Unknown;
     }
 }
Пример #3
0
 public void Disconnect()
 {
     if (m_remoteID != 0)
     {
         Voip.Stop(m_remoteID);
         Object.Destroy(m_remoteHead.GetComponent <VoipAudioSourceHiLevel>(), 0);
         m_remoteID = 0;
         m_state    = PeerConnectionState.Unknown;
     }
 }
Пример #4
0
    void VoipStateChangedCallback(Message <NetworkingPeer> msg)
    {
        Debug.LogFormat("Voip state to {0} changed to {1}", msg.Data.ID, msg.Data.State);

        if (msg.Data.ID == m_remoteID)
        {
            m_state = msg.Data.State;

            if (m_state == PeerConnectionState.Timeout &&
                // ID comparison is used to decide who initiates and who gets the Callback
                PlatformManager.MyID < m_remoteID)
            {
                // keep trying until hangup!
                Voip.Start(m_remoteID);
            }
        }

        PlatformManager.SetBackgroundColorForState();
    }
Пример #5
0
    void ConnectionStateChangedCallback(Message <NetworkingPeer> msg)
    {
        Debug.LogFormat("Connection state to {0} changed to {1}", msg.Data.ID, msg.Data.State);

        if (msg.Data.ID == m_remoteID)
        {
            m_state = msg.Data.State;

            if (m_state == PeerConnectionState.Timeout &&
                // ID comparison is used to decide who calls Connect and who calls Accept
                PlatformManager.MyID < m_remoteID)
            {
                // keep trying until hangup!
                Net.Connect(m_remoteID);
            }
        }

        PlatformManager.SetBackgroundColorForState();
    }
Пример #6
0
        PeerConnectionState EnsurePeerConnectionReported(string peerConnectionId, Message trigger, Queue <Event> buffer)
        {
            PeerConnectionState state;

            if (reportedPeerConnection.TryGetValue(peerConnectionId, out state))
            {
                return(state);
            }
            state = new PeerConnectionState()
            {
                ObjectId                 = peerConnectionId,
                ConnsRootObjectId        = peerConnectionId + ".Connections",
                CandidatesRootObjectId   = peerConnectionId + ".Candidates",
                StreamsRootObjectId      = peerConnectionId + ".Streams",
                ChannelsRootObjectId     = peerConnectionId + ".Channels",
                TracksRootObjectId       = peerConnectionId + ".Tracks",
                CertsRootObjectId        = peerConnectionId + ".Certs",
                DataChannelsRootObjectId = peerConnectionId + ".DataChannels",
                SourcesRootObjectId      = peerConnectionId + ".Sources",
            };
            reportedPeerConnection.Add(peerConnectionId, state);
            buffer.Enqueue(new ObjectCreation(trigger, peerConnectionId, peerConnectionTypeInfo));
            buffer.Enqueue(new ParentChildRelationChange(trigger, peerConnectionId, peerConnectionTypeInfo, peerConnectionsRootObjectId));

            Action <ObjectTypeInfo, string, string> reportCategoryRoot = (typeInfo, objId, displayName) =>
            {
                buffer.Enqueue(new ObjectCreation(trigger, objId, typeInfo, displayName: displayName));
                buffer.Enqueue(new ParentChildRelationChange(trigger, objId, typeInfo, state.ObjectId));
            };

            reportCategoryRoot(connectionsRootTypeInfo, state.ConnsRootObjectId, "Connections");
            reportCategoryRoot(ssrcsRootTypeInfo, state.StreamsRootObjectId, "Streams");
            reportCategoryRoot(candidatesRootTypeInfo, state.CandidatesRootObjectId, "Candidates");
            reportCategoryRoot(channelsRootTypeInfo, state.ChannelsRootObjectId, "Channels");
            reportCategoryRoot(tracksRootTypeInfo, state.TracksRootObjectId, "Tracks");
            reportCategoryRoot(certsRootTypeInfo, state.CertsRootObjectId, "Certificates");
            reportCategoryRoot(dataChannelsRootTypeInfo, state.DataChannelsRootObjectId, "Data channels");
            reportCategoryRoot(mediaSourcesRootTypeInfo, state.SourcesRootObjectId, "Media sources");

            return(state);
        }
Пример #7
0
            public void OnConnectionChange(PeerConnectionState newState)
            {
                _executor.Execute(() =>
                {
                    _logger.Debug(TAG, $"PeerConnectionState: {newState}");
                    switch (newState)
                    {
                    case PeerConnectionState.Connected:
                        _events.OnConnected();
                        break;

                    case PeerConnectionState.Disconnected:
                        _events.OnDisconnected();
                        break;

                    case PeerConnectionState.Failed:
                        _peerConnectionClient.ReportError("DTLS connection failed.");
                        break;
                    }
                });
            }
 public static RTCPeerConnectionState ToPlatformNative(this PeerConnectionState nativePort) => (RTCPeerConnectionState)nativePort;
Пример #9
0
 public NetworkingPeer(UInt64 id, PeerConnectionState state)
 {
     ID    = id;
     State = state;
 }
 public static RTCPeerConnectionState ToNative(this PeerConnectionState self)
 {
     return((RTCPeerConnectionState)self);
 }