#include "includes.hpp"
+#include <unistd.h>
//
if (sock.attach(host, port)==0) {
serv_gets(ServerReady);
initialize_session();
+
+ curr_host = host; // Remember host and port, in case
+ curr_port = port; // we need to auto-reconnect later
+
return(0);
}
else return(1);
// it must begin HERE.
serv_puts(command);
+
+ if (IsConnected() == FALSE) {
+ reconnect_session();
+ serv_puts(command);
+ }
+
serv_gets(response);
+
first_digit = (response.GetChar(0)) - '0';
if (response.GetChar(3) == '*')
+// Reconnect a broken session
+
+void CitClient::reconnect_session(void) {
+ wxString sendcmd;
+
+ CurrentRoom = "__ This is not the name of any valid room __";
+
+ // Give a crashed server some time to restart
+ sleep(5);
+
+ if (attach(curr_host, curr_port) != 0) {
+ // FIX do this more elegantly
+ cout << "Could not re-establish session (1)\n";
+ }
+
+ sendcmd = "USER " + curr_user;
+ if (serv_trans(sendcmd) != 3) {
+ // FIX do this more elegantly
+ cout << "Could not re-establish session (2)\n";
+ }
+
+ sendcmd = "PASS " + curr_pass;
+ if (serv_trans(sendcmd) != 2) {
+ // FIX do this more elegantly
+ cout << "Could not re-establish session (3)\n";
+ }
+}
+
+
// ... and about the user ...
wxString curr_user;
wxString curr_pass;
+ int axlevel;
// Stuff we have to keep track of ...
wxString CurrentRoom;
TCPsocket sock; // transport layer
void serv_gets(wxString& buf); // session layer
void serv_puts(wxString buf); // session layer
+ void reconnect_session(void); // session layer
void download_express_messages(void); // presentation layer
- void CitClient::initialize_session(void); // presentation layer
+ void initialize_session(void); // presentation layer
+
+ wxString curr_host;
+ wxString curr_port;
+
};
extract(citsock->curr_user, serv_response.Mid(4), 0);
BigMDI->SetStatusText(citsock->curr_user, 1);
citsock->GotoRoom("_BASEROOM_", "", junk);
+ citsock->axlevel = extract_int(serv_response.Mid(4), 1);
// FIX ... add code here to perform registration if necessary