Exemplo n.º 1
0
        /// <summary>
        /// Ask signaling server to register current device's public ip address on connectable peer list.<br/>
        /// </summary>
        public void RequestHandshake()
        {
            Debug.LogWarning("requesting handshake.");

            IPPair thisIP = new IPPair(UdpNetwork.GetLocalAddress(), null, 0);

            DataPacket packet = new DataPacket(Header.request_handshake, JsonConvert.SerializeObject(thisIP));

            SendRequest(new Message(packet, signalingServer), Header.response_handshake);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Response for [<see cref="RequestConnection(IPEndPoint)"/>] from peer through signaling server.<br/>
        /// Attempt the connection to peer, now that response have been received.
        /// </summary>
        private void OnResponseConnection(DataPacket packet)
        {
            Debug.LogWarning("requested peer connection is now ready.");

            try
            {
                peerIP = JsonConvert.DeserializeObject <IPPair>(packet.Payload);
                FindPeerOnPublic();
            }
            catch (JsonException e)
            {
                Debug.LogError(e.StackTrace);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Clear peer informations.
 /// </summary>
 private void ClearPeer()
 {
     peerIP = null;
     networkConnectionState.Value = ConnectionState.disconnected;
 }