Example #1
0
        public async void ConnectUDP(NetworkConnectionEndpoint remoteNetworkConnectionEndpoint)
        {
            if (!IsUDPSetup)
            {
                InitUDP();
            }
            if (IsUDPConnected)
            {
                ResetUDP(); InitUDP();
            }

            try
            {
                Debug.WriteLine("Binding UDPPort");
                await m_datagramSocket.BindServiceNameAsync(remoteNetworkConnectionEndpoint.Port);

                Debug.WriteLine("Connecting UDPSocket");
                await m_datagramSocket.ConnectAsync(remoteNetworkConnectionEndpoint.HostName, remoteNetworkConnectionEndpoint.Port);

                Debug.WriteLine("Creating UDPDataWriter");
                m_udpDataWriter = new DataWriter(m_datagramSocket.OutputStream);

                Debug.WriteLine("Completed UDP");
                UDPNetworkConnectionEndpoint = remoteNetworkConnectionEndpoint;
                IsUDPConnected = true;

                Debug.WriteLine("UDP Connected: " + UDPNetworkConnectionEndpoint.ToString());
            }
            catch (Exception ex) { Debug.WriteLine(DebugTools.PrintOutException("ConnectUDP", ex)); }
        }
Example #2
0
        private void connectButton_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(ipAddressPortTextBox.Text))
            {
                return;
            }

            lanHelper.ConnectUDP(NetworkConnectionEndpoint.Parse(ipAddressPortTextBox.Text));
        }
Example #3
0
        public async void StartTCPServer(NetworkConnectionEndpoint remoteNetworkConnectionEndpoint)
        {
            if (!IsTCPSetup)
            {
                InitTCP();
            }
            if (IsTCPConnected)
            {
                ResetTCP(); InitTCP();
            }

            try
            {
                Debug.WriteLine("Binding TCP Port");
                await m_streamSocketListener.BindServiceNameAsync(remoteNetworkConnectionEndpoint.Port);

                TCPNetworkConnectionEndpoint = remoteNetworkConnectionEndpoint;
                Debug.WriteLine("TCP Connected: " + TCPNetworkConnectionEndpoint.ToString());
            }
            catch (Exception ex) { Debug.WriteLine(DebugTools.PrintOutException("StartTCPServer", ex)); }
        }
Example #4
0
        public async void ConnectTCP(NetworkConnectionEndpoint remoteNetworkConnectionEndpoint)
        {
            if (!IsTCPSetup)
            {
                InitTCP();
            }
            if (IsTCPConnected)
            {
                ResetTCP(); InitTCP();
            }

            try
            {
                Debug.WriteLine("Connecting TCPSocket");
                await m_streamSocket.ConnectAsync(remoteNetworkConnectionEndpoint.HostName, remoteNetworkConnectionEndpoint.Port);

                TCPNetworkConnectionEndpoint = remoteNetworkConnectionEndpoint;
                Debug.WriteLine("TCP Connected: " + TCPNetworkConnectionEndpoint.ToString());

                await DoConnectTCP();
            }
            catch (Exception ex) { Debug.WriteLine(DebugTools.PrintOutException("ConnectTCP", ex)); }
        }
Example #5
0
        public void ResetTCP()
        {
            TCPNetworkConnectionEndpoint = new NetworkConnectionEndpoint();

            IsTCPSetup     = false;
            IsTCPConnected = false;
            IsTCPListening = false;

            // Dispose of potentially used assets
            if (m_streamSocketListener != null)
            {
                m_streamSocketListener.Dispose();
            }

            if (m_tcpDataReader != null)
            {
                m_tcpDataReader.Dispose();
            }

            if (m_tcpDataWriter != null)
            {
                m_tcpDataWriter.Dispose();
            }

            if (m_streamSocket != null)
            {
                m_streamSocket.Dispose();
            }

            // Set them to null now
            m_streamSocketListener = null;
            m_streamSocket         = null;
            m_tcpDataReader        = null;
            m_tcpDataWriter        = null;

            Debug.WriteLine("Resetting TCP");
        }
Example #6
0
        public void ResetUDP()
        {
            UDPNetworkConnectionEndpoint = new NetworkConnectionEndpoint();

            IsUDPSetup     = false;
            IsUDPConnected = false;

            // Dispose of potentially used assets
            if (m_udpDataWriter != null)
            {
                m_udpDataWriter.Dispose();
            }

            if (m_datagramSocket != null)
            {
                m_datagramSocket.Dispose();
            }

            // Set them to null for reuse
            m_datagramSocket = null;
            m_udpDataWriter  = null;

            Debug.WriteLine("Resetting UDP");
        }