Exemplo n.º 1
0
        public void startConnecting(ConnectedDelegate receivingFunc)
        {
            this.receivingFunc = receivingFunc;
            needToStop         = false;
            string hostName = System.Net.Dns.GetHostName();

            System.Net.IPAddress broadcastIp = null;
            foreach (System.Net.IPAddress cur in System.Net.Dns.GetHostEntry(hostName).AddressList)
            {
                if ((cur.ToString()).StartsWith("192"))
                {
                    broadcastIp = cur;
                    break;
                }
            }
            try
            {
                string strIp = broadcastIp.ToString();
                broadcastIp = System.Net.IPAddress.Parse(strIp.Substring(0, strIp.LastIndexOf(".") + 1) + 255);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e);
            }

            context = SynchronizationContext.Current;
            Task.Factory.StartNew(() => tryToReceiveIP(broadcastIp));
        }
Exemplo n.º 2
0
        protected virtual void OnConnected()
        {
            ConnectedDelegate handler = Connected;

            if (handler != null)
            {
                handler(this);
            }
        }
Exemplo n.º 3
0
        private void ClarifyConnected(PengSW.TcpService.Connection aConnection)
        {
            ConnectedDelegate aTempEvent = Connected;

            if (aTempEvent != null)
            {
                aTempEvent(this, aConnection);
            }
        }
Exemplo n.º 4
0
        public RoboticsDeviceInfo(BluetoothDeviceInfo di)
        {
            this.Device        = di;
            this.DeviceName    = di.DeviceName;
            this.DeviceAddress = di.DeviceAddress;

            BTEndPoint = new BluetoothEndPoint(this.DeviceAddress, BluetoothService.SerialPort);

            connectedDelegate = this.Connected;
        }
Exemplo n.º 5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            _connected    = Connected;
            _disconnected = Disconnected;
            _message      = Message;

            _server               = new IpcLib.Server.IpcServer("ipc-winforms");
            _server.Connected    += ConnectedAsync;
            _server.Disconnected += DisconnectedAsync;
            _server.Message      += MessageAsync;
        }
Exemplo n.º 6
0
        private void OnLoad(object?sender, EventArgs e)
        {
            _connected    = Connected;
            _disconnected = Disconnected;
            _message      = Message;

            _client               = new IpcClient("ipc-winforms");
            _client.Connected    += ConnectedAsync;
            _client.Disconnected += DisconnectedAsync;
            _client.Message      += MessageAsync;
        }
Exemplo n.º 7
0
        // Create asnyc connection.
        public void Connect(string host, ushort port, ConnectedDelegate onConnected)
        {
            if (mTcp == null)
            {
                mTcp = new TcpClient(AddressFamily.InterNetwork);
            }
            else
            {
                Disconnect();
            }

            mHost       = host;
            mPort       = port;
            OnConnected = onConnected;
            LogMgr.I("{0} Begin connection.", info);
            mTcp.BeginConnect(mHost, mPort, new AsyncCallback(asyncConnect), mTcp);
        }
Exemplo n.º 8
0
        private void p2pFileTransmit1_fileTransmitConnected(object sender, NetCommunicationClass netClass)
        {
            try
            {
                ConnectedDelegate d = new ConnectedDelegate(Connected);
                this.BeginInvoke(d, sender, netClass);
            }
            catch (Exception)
            {

            }
        }