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)); }
protected virtual void OnConnected() { ConnectedDelegate handler = Connected; if (handler != null) { handler(this); } }
private void ClarifyConnected(PengSW.TcpService.Connection aConnection) { ConnectedDelegate aTempEvent = Connected; if (aTempEvent != null) { aTempEvent(this, aConnection); } }
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; }
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; }
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; }
// 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); }
private void p2pFileTransmit1_fileTransmitConnected(object sender, NetCommunicationClass netClass) { try { ConnectedDelegate d = new ConnectedDelegate(Connected); this.BeginInvoke(d, sender, netClass); } catch (Exception) { } }