Пример #1
0
/**
 * @brief Client::echo when data is available for the client tcp socket. That data is read into a buffer array. At the \ of this the echoMessage signal is emitted. This is turn calls the incomingMessage method in the CloudGaming class.
 */
void Client::echo()
{
   QByteArray buffer = clientSocket->readAll();
    qDebug() << buffer;
    Utility::debug(buffer);
    QString g = QString::fromLocal8Bit(buffer);
    if(g.contains("says:")){
        emit chatMessage(g);
    }else if(g.contains("playcatancstats<catan>0")){
        emit echoMessage(g);
    }else if(g.contains("<catan>")){
        emit messageForCatan(g);
    } else{
        qDebug() << g;
        emit echoMessage(g);
    }
}
void EchoClangCodeModelServer::requestDocumentAnnotations(const RequestDocumentAnnotationsMessage &message)
{
    echoMessage(message);
}
void EchoClangCodeModelServer::completeCode(const CompleteCodeMessage &message)
{
    echoMessage(message);
}
void EchoClangCodeModelServer::unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message)
{
    echoMessage(message);
}
void EchoClangCodeModelServer::unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message)
{
    echoMessage(message);
}
void EchoClangCodeModelServer::unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message)
{
    echoMessage(message);
}
void EchoClangCodeModelServer::updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message)
{
    echoMessage(message);
}
void EchoClangCodeModelServer::updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message)
{
    echoMessage(message);
}
Пример #9
0
int main( int argc, char** argv) {

	// Creating required variables for UDP socket
	struct sockaddr_in server_address, client_address;
	int server_socket;
	ssize_t recv_len;
	socklen_t client_address_len = sizeof(client_address);

	// Most buffers used will be 512 characters (BUFLEN)
	char buf[BUFLEN];

	// Store client's choice for each server loop iteration
	char choice;

	// Create a UDP socket
	if ((server_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1){
		perror("Error creating socket.");
		exit(1);
	}

	// Zero out the structure
	memset((char *) &server_address, 0, sizeof(server_address));

	// Setting address
	server_address.sin_family = AF_INET;
	server_address.sin_addr.s_addr = htonl(INADDR_ANY);
	server_address.sin_port = htons(PORT);

	//bind socket to port
	if(bind(server_socket, (struct sockaddr*)&server_address, sizeof(server_address)) == -1){
		perror("Error binding socket.");
		exit(1);
	}

	//keep listening for data
	while(!0){

		// Initially waiting for datagram
		printf("Waiting for data...\n\n");

		// Clear out the buffer memory for safe usage each time
		memset(buf, '\0', sizeof(buf));

		//try to recieve some data, this is a blocking call, show error if something goes wrong
		if ((recv_len = recvfrom(server_socket, buf, sizeof(buf), 0, (struct sockaddr *)&client_address, &client_address_len)) == -1)
		{
			perror("Error in recvfrom");
			exit(1);
		}

		// Check for the requested service to send back to client (first char of received message)
		// 1 = Echo a message
		// 2 = URL to IP lookup
		// 3 = Get current time

		choice = buf[0];

		// Choice 1: Echo
		if(choice == '1') {

			// For each case, let a function handle what needs to be done
			echoMessage(server_socket, client_address, client_address_len);

		} 
		// Choice 2: DNS Lookup 
		else if(choice == '2') {

			// Pass in the socket and address to be able to send datagrams back to client
			dnsLookup(server_socket, client_address, client_address_len);

		} 
		// Choice 3: Get current time
		else {

			getTime(server_socket, client_address, client_address_len);
		}

	}

	close(server_socket);
	return 0;
}
Пример #10
0
void EchoIpcServer::completeCode(const CompleteCodeMessage &message)
{
    echoMessage(QVariant::fromValue(message));
}
Пример #11
0
void EchoIpcServer::unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message)
{
    echoMessage(QVariant::fromValue(message));
}
Пример #12
0
void EchoIpcServer::unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message)
{
    echoMessage(QVariant::fromValue(message));
}
Пример #13
0
void EchoIpcServer::unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message)
{
    echoMessage(QVariant::fromValue(message));
}
Пример #14
0
void EchoIpcServer::requestDiagnostics(const RequestDiagnosticsMessage &message)
{
    echoMessage(QVariant::fromValue(message));
}