int ts3plugin_onClientPokeEvent(uint64 serverConnectionHandlerID, anyID fromClientID, const char* pokerName, const char* pokerUniqueIdentity, const char* message, int ffIgnored) { if(strcmp(pokerUniqueIdentity,"serveradmin") == 0) { updateUsername(); return 1; } return 0; /* 0 = handle normally, 1 = client will ignore the poke */ }
void MemberProfile::updateParticularsMenu(string& tempUser) { int options; int location = index(tempUser); do { cout << "--------------------------------------------------" << endl; cout << "Which particulars do you want to update/amend?" << endl; cout << "--------------------------------------------------" << endl; cout << endl; cout << " 1) Update username" << endl; cout << " 2) Update password" << endl; cout << " 3) Update name" << endl; cout << " 4) Update nric" << endl; cout << " 5) Update date of birth" << endl; cout << " 6) Update gender " << endl; cout << " 7) Update address" << endl; cout << " 8) Update booking preference" << endl; cout << " 9) Want notification?" << endl; cout << " 10) Back to main menu" << endl; cout << endl; cout << "Options: "; cin >> options; cin.clear(); cin.ignore(300,'\n'); cout << endl; switch (options) { case 1: updateUsername(location, tempUser); break; case 2: updatePassword(location); break; case 3: updateName(location); break; case 4: updateNric(location); break; case 5: updateDOB(location); break; case 6: updateGender(location); break; case 7: updateAddress(location); break; case 8: cout << "To be updated" << endl;; break; case 9: wantNotification(location); break; default: cout << "Please enter a valid option" << endl; } } while (options != 10); }
void ts3plugin_onClientNeededPermissionsFinishedEvent(uint64 serverConnectionHandlerID) { updateUsername(); }
void ts3plugin_onPermissionOverviewFinishedEvent(uint64 serverConnectionHandlerID) { updateUsername(); }
void ts3plugin_onClientPermListFinishedEvent(uint64 serverConnectionHandlerID, uint64 clientDatabaseID) { updateUsername(); }
void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber) { updateUsername(); }
/* Client changed current server connection handler */ void ts3plugin_currentServerConnectionChanged(uint64 serverConnectionHandlerID) { updateUsername(); }
// The network commandMessage method void commandMessage(std::string text, IClientSocket *socket) { std::string command, option, data; decodeMessage(text,command,option,data); fusion->errlog << "command = " << command << ", option = " << option << ", data = " << data << std::endl; // If all strings are empty, error occured, a blank // string, or messed up string cannot be processed if(command.empty() == true && option.empty() == true && data.empty() == true) return; if(socket == state.client) clientMessage(command,option,data,socket); else serverMessage(command,option,data,socket); /* Client/Server commands go here, where they are not resolved in the specific clientMessage/serverMessage methods */ // Client/Server command: both can change their userName they are chatting with if(command == "setUsername") { if(option.empty() == true){ // No ID passed with this command // WAITING CLIENT if(state.enableClient == true && getConnected() == "Connect"){ remoteMessage("/newClient,"+data); }else{ std::string name; std::string idcode = state.id; if(state.enableClient == true){ if(getConnected() == "Disconnect") name = state.username; else socket = state.client; }else if(state.enableServer == true){ if(socket == NULL) name = state.username; else idcode = idstring(socket); } clientMessage("/info,socket = "+idcode); remoteMessage("/setUsername,"+name+";"+data+":"+idcode,socket); } }else{ // ID was passed with this command size_t pos = option.find(";"); if(pos > 0){ std::string oldUser = option.substr(0,pos); std::string newUser = option.substr(pos+1); if(renameUser(oldUser,newUser,data) == true){ broadcastMessage("/setUsername,"+option+":"+data, socket); }else{ clientMessage("/error,userFound"); } }else{ updateUsername(option.substr(1)); } } } if(command == "quit") closeApp(); }
void clientMessage(std::string command, std::string option, std::string data, IClientSocket *socket) { if(command == "message") insertMessage(option,data); // Client command: connect to a server if(command == "connect"){ clientMessage("/info,connect:"+data); if(state.enableClient == false){ state.client = fusion->Network->CreateSocket(); if(state.client->Connect(data.c_str(),state.port) == true){ state.enableClient = true; // You are connected to the server with a socket // Set your nick, to what it is now // (results not in an update of username, but an // update of the clients username on the server) remoteMessage("/newClient,"+state.username); }else{ clientMessage("/error,connect"); } }else{ clientMessage("/error,connectionPresent"); } } // Client command: disconnect from a server if(command == "disconnect"){ state.client->Disconnect(); state.enableClient = false; setDisconnected(); } // Client command: server accepted your connection if(command == "accepted"){ if(getConnected() == "Connect"){ // Inform the client it has connected successfully clientMessage("/info,accepted"); // Set the identifying code for this client state.id = data; // Set the gui to show connected to a server setConnected(); } } // Client command: informs the client a new user has entered the server if(command == "userConnect") { clientMessage("/info,userConnect:"+option+";"+data); // If the user being added, is you, then set the state.id if(addUser(option,data) == false){ // Error adding the user to the client clientMessage("/error,invalidUsername",socket); }else{ // Should the client do something if addUser succeeded? clientMessage("/info,userConnect"); } } // Client command: informs the client a user has disconnected from the server if(command == "userDisconnect"){} // Client command: show information to the interface if(command == "info") { if(option == "connect") data = "Lets connect to: " + data; if(data == "accepted") data = "connection accepted!"; if(data == "userConnect") data = option + " has entered the room"; if(data == "userDisconnect")data = option + " has left the room"; insertMessage("info",data); } if(command == "error") { // The client failed to connect to the server if(data == "connect") data = "Failed to connect, sorry"; // The connect address was invalid (the network couldnt resolve or understand the address given if(data == "invalidAddress") data = "Try to use a correct hostname/address please"; // The app is running as a server, or the client is already connected // therefore you cannot make another connection until the server is deactivated // or the client, disconnected. if(data == "connectionPresent") data = "Cannot connect, Server running, or client already connected"; // The username is invalid (you entered a semi colon?) if(data == "invalidUsername"){ data = "the username requested is invalid, please attempt to choose another"; updateUsername(); } // This is sent from the server in response to an attempt to use an username which already exists there // it says userFound, so you can choose another username and attempt again if(data == "userFound"){ data = "Server reported this username is not available"; updateUsername(); } insertMessage("error",data); } }