public SourceTable GetSourceTable() { this.InitializeSocket(); sckt.Blocking = true; this.Connect(); sckt.Send(CreateRequest("")); string responseData = ""; System.Threading.Thread.Sleep(1000); //Wait for response while (sckt.Available > 0) { byte[] returndata = new byte[sckt.Available]; sckt.Receive(returndata); //Get response responseData += System.Text.Encoding.ASCII.GetString(returndata, 0, returndata.Length); System.Threading.Thread.Sleep(100); //Wait for response } this.Close(); if (!responseData.StartsWith("SOURCETABLE 200 OK")) { return(null); } SourceTable result = new SourceTable(); foreach (string line in responseData.Split('\n')) { if (line.StartsWith("STR")) { result.DataStreams.Add(NTRIP.SourceTable.NTRIPDataStream.ParseFromString(line)); } else if (line.StartsWith("CAS")) { result.Casters.Add(NTRIP.SourceTable.NTRIPCaster.ParseFromString(line)); } else if (line.StartsWith("NET")) { result.Networks.Add(NTRIP.SourceTable.NTRIPNetwork.ParseFromString(line)); } } return(result); }
public SourceTable GetSourceTable() { this.InitializeSocket(); sckt.Blocking = true; this.Connect(); sckt.Send(CreateRequest("")); string responseData = ""; System.Threading.Thread.Sleep(1000); //Wait for response while (sckt.Available>0) { byte[] returndata = new byte[sckt.Available]; sckt.Receive(returndata); //Get response responseData += System.Text.Encoding.ASCII.GetString(returndata, 0, returndata.Length); System.Threading.Thread.Sleep(100); //Wait for response } this.Close(); if (!responseData.StartsWith("SOURCETABLE 200 OK")) return null; SourceTable result = new SourceTable(); foreach (string line in responseData.Split('\n')) { if(line.StartsWith("STR")) result.DataStreams.Add(NTRIP.SourceTable.NTRIPDataStream.ParseFromString(line)); else if (line.StartsWith("CAS")) result.Casters.Add(NTRIP.SourceTable.NTRIPCaster.ParseFromString(line)); else if (line.StartsWith("NET")) result.Networks.Add(NTRIP.SourceTable.NTRIPNetwork.ParseFromString(line)); } return result; }