Go to the documentation of this file.
36 #ifndef ECHOLINK_DIRECTORY_INCLUDED
37 #define ECHOLINK_DIRECTORY_INCLUDED
46 #include <sigc++/sigc++.h>
60 #include <AsyncTcpClient.h>
61 #include <AsyncTimer.h>
130 class Directory :
public sigc::trackable
146 const Async::IpAddress &bind_ip=Async::IpAddress());
221 const std::vector<std::string>&
servers(
void)
const {
return the_servers; }
233 const std::string&
callsign(
void)
const {
return the_callsign; }
245 const std::string&
password(
void)
const {
return the_password; }
261 const std::string&
description(
void)
const {
return the_description; }
271 const std::list<StationData>&
links(
void)
const {
return the_links; }
283 return the_repeaters;
295 const std::list<StationData>&
conferences(
void)
const
297 return the_conferences;
304 const std::list<StationData>&
stations(
void)
const {
return the_stations; }
314 const std::string&
message(
void)
const {
return the_message; }
343 const std::string& code,
bool exact=
true);
360 sigc::signal<void, const std::string&>
error;
367 CS_WAITING_FOR_START, CS_WAITING_FOR_COUNT, CS_WAITING_FOR_CALL,
368 CS_WAITING_FOR_DATA, CS_WAITING_FOR_ID, CS_WAITING_FOR_IP,
369 CS_WAITING_FOR_END, CS_IDLE, CS_WAITING_FOR_OK
372 static const int DIRECTORY_SERVER_PORT = 5200;
373 static const int REGISTRATION_REFRESH_TIME = 5 * 60 * 1000;
374 static const int CMD_TIMEOUT = 120 * 1000;
377 std::vector<std::string> the_servers;
378 std::string the_callsign;
379 std::string the_password;
380 std::string the_description;
381 std::list<StationData> the_links;
382 std::list<StationData> the_repeaters;
383 std::list<StationData> the_stations;
384 std::list<StationData> the_conferences;
385 std::string the_message;
386 std::string error_str;
390 std::list<StationData> get_call_list;
392 DirectoryCon * ctrl_con;
393 std::list<Cmd> cmd_queue;
395 Async::Timer * reg_refresh_timer;
398 Async::Timer * cmd_timer;
399 Async::IpAddress bind_ip;
404 void printBuf(
const unsigned char *buf,
int len);
405 int handleCallList(
char *buf,
int len);
407 void ctrlSockReady(
bool is_ready);
408 void ctrlSockConnected(
void);
409 void ctrlSockDisconnected(
void);
410 int ctrlSockDataReceived(
void *ptr,
unsigned len);
411 void sendNextCmd(
void);
412 void addCmdToQueue(Cmd cmd);
414 void createClientObject(
void);
415 void onRefreshRegistration(Async::Timer *timer);
416 void onCmdTimeout(Async::Timer *timer);
417 bool stationCodeEq(
const StationData& stn, std::string code,
bool exact);
~Directory(void)
Destructor.
static const unsigned MAX_DESCRIPTION_SIZE
Namespace to encapsulate EchoLink communication classes.
sigc::signal< void, StationData::Status > statusChanged
A signal that is emitted when the registration status changes.
std::string statusStr(void) const
Return the current status of the registration in string representation.
A class for accessing an EchoLink directory server.
const std::string & message(void) const
Get the message returned by the directory server.
const StationData * findStation(int id)
Find a station in the station list given a station ID.
const std::list< StationData > & stations(void) const
Get a list of all active "normal" stations.
void setServers(const std::vector< std::string > &servers)
Set the hostname or IP-address of the EchoLink servers to use.
A class for representing data for a station.
void refreshRegistration(void)
Refresh the current registration in the directory server.
void setCallsign(const std::string &callsign)
Set the callsign to use when logging in to the server.
const std::string & password(void) const
Get the password that is used when logging in to the server.
const StationData * findCall(const std::string &call)
Find a callsign in the station list.
void findStationsByCode(std::vector< StationData > &stns, const std::string &code, bool exact=true)
Find stations from their mapping code.
void makeOnline(void)
Login to the directory server and set status to online.
const std::list< StationData > & links(void) const
Get a list of all active links.
Contains a class that represent station data.
const std::vector< std::string > & servers(void) const
Get the name of the remote host.
sigc::signal< void > stationListUpdated
A signal that is emitted when the station list has been updated.
std::string statusStr(void) const
Return the string representation of the status.
void makeBusy(void)
Login to the directory server and set status to busy.
void getCalls(void)
Get the station list from the directory server.
std::ostream & operator<<(std::ostream &os, const StationData &station)
sigc::signal< void, const std::string & > error
A signal that is emitted when an error occurs.
const std::string & description(void) const
Get the description that is used when registering in the server.
void makeOffline(void)
Logout from the directory server.
const std::list< StationData > & conferences(void) const
Get a list of all active conferences.
void setPassword(const std::string &password)
Set the password to use when logging in to the server.
const std::string & callsign(void) const
Get the callsign that is used when logging in to the server.
void setDescription(const std::string &description)
Set the description to register in the server.
const std::list< StationData > & repeaters(void) const
Get a list of all active repeasters.
Directory(const std::vector< std::string > &servers, const std::string &callsign, const std::string &password, const std::string &description="", const Async::IpAddress &bind_ip=Async::IpAddress())
Constructor.
StationData::Status status(void) const
Return the current status of the registration.