private void SocketDataReceived(object sender, DataReceivedEventArgs e) { string response = Encoding.UTF8.GetString(e.Data); var device = JsonObject.Parse(response); var hostName = device.GetNamedString("hostname"); if (hostName.Split('-')[0] != "Roomba") { return; } var macAddr = device.GetNamedString("mac"); string mac = macAddr.Replace(":", ""); if (this.AlreadyDiscovered(mac)) { return; } var blid = hostName.Split('-')[1]; var pass = "******"; var conn = new RoombaClient(e.RemoteAddress, "8883", blid, pass); conn.Disconnected += (object s, EventArgs args) => { this.RemoveDevice(mac); }; this.AddDevice(mac, conn); }
internal RoombaDevice(RoombaAdapter adapter, RoombaClient conn, string Name, string VendorName, string Model, string Version, string SerialNumber, string Description) : base(adapter, Name, VendorName, Model, Version, SerialNumber, Description) { _conn = conn; }