Exemplo n.º 1
0
    public void CreateOffer()
    {
        int iOpenPort = GetOpenPort();

        IPAddress ipAddress = GetLocalIPAddress();

        Address ipaAddress = new Address()
        {
            address = ipAddress.ToString(), port = iOpenPort
        };

        if (ipAddress == null)
        {
            Debug.LogError("Failed to get ip address");

            return;
        }

        try
        {
            //create listen port
            BeginReceivingMessages(iOpenPort);
        }
        catch (Exception excException)
        {
            Debug.LogError($"Failed to setup listener due to error{excException.Message}");

            return;
        }

        try
        {
            string strOffer = JsonUtility.ToJson(ipaAddress);

            //fire event for offer made
            LocalSdpReadytoSend?.Invoke(c_strConnectionType, strOffer);
        }
        catch
        {
            Debug.LogError("Error serializing offer message");
        }
    }
Exemplo n.º 2
0
    public void CreateAnswer()
    {
        //get listening port values
        int iOpenPort = GetOpenPort();

        IPAddress ipAddress = GetLocalIPAddress();

        Address ipaAddress = new Address()
        {
            address = ipAddress.ToString(), port = iOpenPort
        };

        if (ipAddress == null)
        {
            Debug.LogError("Failed to get ip address");

            return;
        }

        try
        {
            //create listen port
            BeginReceivingMessages(iOpenPort);
        }
        catch
        {
            Debug.Log("Failed to create offer");
        }

        try
        {
            string strOffer = JsonUtility.ToJson(ipaAddress);

            //fire event for offer made
            LocalSdpReadytoSend?.Invoke(c_strConnectionType, strOffer);
        }
        catch
        {
            Debug.LogError("Error serializing answer message");
        }
    }
Exemplo n.º 3
0
 public static extern bool RegisterOnLocalSdpReadytoSend(int peerConnectionId,
                                                         LocalSdpReadytoSend callback,
                                                         IntPtr userData);