Exemple #1
0
void RootData::sendContents(Bridge & b) const
{
    sendId(b);
    sendParent(b);
    sendStamp(b);
    sendObjtype(b);
    sendName(b);
    BaseObjectData::sendContents(b);
}
Exemple #2
0
int main(){
	
	atexit(shut);
	init();
	sendName();
	pthread_t tid;
	//pthread_create(&tid,NULL,recvMsg,&sockfd);

	while(1){
		char buf[100];
		printf("请输入:");
		scanf("%s",buf);
		if(!strcmp(buf,"bye"))
			break;
		int res = send(sockfd,buf,strlen(buf),0);
		judge1(res,send);
		printf("成功向服务器发送数据%s(%d)\n",buf,res);
	}
	return 0;
}
XAirAuxBlock::XAirAuxBlock(MainController* controller, QString uid)
    : OneInputBlock(controller, uid)
    , m_panNode(nullptr)
    , m_onNode(nullptr)
    , m_channelNumber(this, "channelNumber", 1, 1, 32)
    , m_bus(this, "bus", 0, 0, 16)
    , m_faderPos(this, "faderPos", 0.0, 0, 1)
    , m_pan(this, "pan", 0.5)
    , m_boost(this, "boost", true)
    , m_on(this, "on", true)
    , m_pauseValueTransmission(false)
{
    m_heightIsResizable = true;

    m_panNode = createInputNode("panNode");
    m_onNode = createInputNode("onNode");

    m_onNode->enableImpulseDetection();
    connect(m_onNode, &NodeBase::impulseBegin, [this](){ m_on = true; });
    connect(m_onNode, &NodeBase::impulseEnd, [this](){ m_on = false; });

    m_subscribeRefreshTimer.setInterval(10000);  // 10s
    connect(&m_subscribeRefreshTimer, SIGNAL(timeout()), this, SLOT(updateSubscription()));
    m_subscribeRefreshTimer.start();

    connect(&m_faderPos, SIGNAL(valueChanged()), this, SIGNAL(decibelChanged()));

    connect(&m_label, SIGNAL(valueChanged()), this, SLOT(sendName()));
    connect(&m_faderPos, SIGNAL(valueChanged()), this, SLOT(sendFaderPos()));
    connect(&m_pan, SIGNAL(valueChanged()), this, SLOT(sendPan()));
    connect(&m_on, SIGNAL(valueChanged()), this, SLOT(sendOn()));

    connect(&m_channelNumber, SIGNAL(valueChanged()), this, SLOT(retrieveStateFromConsole()));
    connect(&m_bus, SIGNAL(valueChanged()), this, SLOT(retrieveStateFromConsole()));

    connect(m_inputNode, &NodeBase::dataChanged, [this](){ m_faderPos.setValue(m_inputNode->getValue()); });
    connect(m_panNode, &NodeBase::dataChanged, [this](){ m_pan.setValue(m_panNode->getValue()); });

    connect(controller->audioConsole(), SIGNAL(messageReceived(OSCMessage)), this, SLOT(onMessageReceived(OSCMessage)));

}
void MyControlBox::receiveClickedNode(Node* node, int control){
	if (g != NULL) {
		g->widget->updateDisplay = 0;
	}
	if (control == 1){
		setValue(node->getScale()[1][1]);
	}
	else if (control == 2) {
		setValue(node->getTranslation()[0][2]);
	}
	else if (control ==3){
		setValue(node->getTranslation()[1][2]);
		
	}
	else if( control == 4){
		float rotate = node->rotateValue;
		if (node->hasGeometry()){
			setValue(node->getPolygon()->getSides());
		//	cout<<"GEOMETRY FOUND" << node->getPolygon()->getSides()<<endl;
			float* colors = (node->getPolygon())->getColors();
			float red = colors[0];
			float green = colors[1];
			float blue = colors[2];
			emit passData(red, green, blue, rotate, node->hasGeometry(), 0 );
		}
		else {
			setValue(0);
			emit passData(0,0,0,rotate,0,0);
		}
		emit sendName(node->getName());
		


	}
	if (g != NULL) {
		g->widget->updateDisplay = 1;
	}
	emit sendClickedNode(node, (++control));
	
}
Exemple #5
0
void Client::slotReadyRead()
{
	QDataStream in(_socket);
	in.setVersion(QDataStream::Qt_4_8);	
	for (;;)
	{
		if (!_nextBlockSize)
		{
			if (_socket->bytesAvailable() < sizeof(quint16))
				break;
			in >> _nextBlockSize;
		}
		
		if (_socket->bytesAvailable() < _nextBlockSize)
		{
			_nextBlockSize = 0;
			break;
		}
		
		quint8 receivedActionCode;
		in >> receivedActionCode;
		
		if (!_isAuthorized
			&& receivedActionCode != _action_UserList
			&& receivedActionCode != _error_NameIsNotValid
			&& receivedActionCode != _error_NameIsUsed
			)
		{
            return;
		}
		
		QString receivedMessage;
		QString receiver;
		QByteArray byteArray;
		
		switch (receivedActionCode)
		{
			case _action_UserList:
				int numberOfUsers;
				in >> numberOfUsers;
				for (int i = 0; i < numberOfUsers; ++i)
				{
					in >> receivedMessage; //names of users
					_userList.append(receivedMessage);
				}
				if (!_isAuthorized)
				{
					_isAuthorized = true;
					_gui->authorizationPassed();
				}
				_gui->passListOfUsers(_userList);				
				break;
			case _action_PublicMessage:
				in >> receiver >> receivedMessage;
				_gui->publicMessage(receiver, receivedMessage);
				break;
			case _action_PrivateMessage:
				in >> receiver >> receivedMessage;
				_gui->privateMessage(receiver, receivedMessage);
				break;
			case _action_YourMessage:
				in >> receiver >> receivedMessage;
				_gui->yourMessage(receiver, receivedMessage, _nameUser);
				break;
			case _action_UserJoin:
				in >> receivedMessage; //name
				_userList.append(receivedMessage);
				_gui->userJoin(receivedMessage);
				break;
			case _action_UserLeft:
				in >> receivedMessage; //name
				_userList.removeAt(_userList.indexOf(receivedMessage));
				_gui->userLeft(receivedMessage);
				break;
			case _error_NameIsNotValid:
				_nameUser = "";
				_gui->nameIsNotValid();
				sendName();
				break;
			case _error_NameIsUsed:
				_nameUser = "";
				_gui->nameIsUsed();
				sendName();
				break;
			case _action_StartVideoStream:
				in >> receivedMessage >> byteArray;
				_gui->showMessage(receivedMessage);
				if (!_gui->StartVideoStream(receivedMessage, byteArray))
				{
					qDebug() << "Error : File is not saved";
					_gui->showError("File is not saved");
				}
				break;
			case _error_FileIsNotOpened:
				qDebug() << "Error : File is not opened";
				_gui->showError("File is not opened");
				break;
		}
		_nextBlockSize = 0;
	}
}
Exemple #6
0
void Client::slotConnected()
{
	_gui->connectEstablished();
	sendName();
}
Exemple #7
0
/*********************parent process tcp connection use to manage************************/
void client_mgr(char *ip, int serverPort, int pipefd, int pid)
{
    int flag = 0;
    char *p;
    char name[256], passwd[256];
    char realName[512];
    int err, fd, i;
    struct sockaddr_in sa;
    char buf[4096];
    SSL_CTX* ctx;
    SSL* ssl;
     
    //create a TCP socket
    fd = socket (AF_INET, SOCK_STREAM, 0);
    CHK_ERR(fd, "socket");
    memset (&sa, 0, sizeof(sa));
    sa.sin_family = AF_INET;
    sa.sin_addr.s_addr = inet_addr(ip);  
    sa.sin_port = htons(serverPort);    

    //connect step
    err = connect(fd, (struct sockaddr*) &sa, sizeof(sa));
    CHK_ERR(err, "connect");
    sleep(2);
    puts("Please input the common name: ");
    scanf("%s", realName);
    setupCTX(&ctx);

    //build SSL on the TCP connection
    ssl = SSL_new(ctx);
    CHK_NULL(ssl);   
    SSL_set_fd (ssl, fd);
    err = SSL_connect(ssl);   
    CHK_SSL(err);

    //check certificate
    SSL_CTX_load_verify_locations(ctx, CACERT, NULL);
    SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL);
    int result = SSL_get_verify_result(ssl);
    if(result == X509_V_OK || result == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) {
	printf("The certificate is valid.\n");
    }
    else {
        printf("Invalid certificate %d\n", result);
        exit(1);
    }
    X509* server_cert = SSL_get_peer_certificate(ssl);
    CHK_NULL(server_cert);
    char *str = X509_NAME_oneline(X509_get_subject_name(server_cert),0,0);
    CHK_NULL(str);
    OPENSSL_free(str);

    str = X509_NAME_oneline(X509_get_issuer_name(server_cert),0,0);
    CHK_NULL(str);
    OPENSSL_free(str);

    X509_NAME *xname = X509_get_subject_name(server_cert);
    X509_NAME_get_text_by_NID(xname, NID_commonName, commonName, 512);
    if( strcasecmp(commonName, realName) !=0 )
    {
        printf("commonName is wrong.\n");
        exit(1);
    }
    printf("commonName is right.\n");
    printf("Server authentication is successful.\n");
    //release!
    X509_free(server_cert);
    sleep(2); 

    while(!flag)
    {
        //handle the login part
        printf("username: "******"%s",name);  
        getchar();
	//safe mode
        set_disp_mode(STDIN_FILENO, 0);  
     
	
        getpasswd(passwd, sizeof(passwd));    
        p = passwd;  
        while(*p != '\n')  
        p++;  
        *p = '\0';

	//OK!
        set_disp_mode(STDIN_FILENO, 1);  
        sendName(ssl, name);
        sendPass(ssl, passwd);
        SSL_read(ssl, buf, sizeof(buf) - 1);
        putchar(10);
        if( buf[0] == 'o' )
        {
            puts("Connect successfully");
            flag = 1;
        }
        else {
            puts("wrong password, please try again!");
        }
    }
    
    //clean the password for security reason
    memset(passwd, 0, sizeof(passwd));

    genKey(key);
    sendKey(ssl, key);
    
    while (1) {
	 talkToudp(key, pipefd, 'k');
   	 printf("1. ipnut 'q' to quit.\n");
         printf("2. input 'c' to change the key.\n");
   	 scanf("%s", buf);
   	 if (strlen(buf) == 1) {
		 if (buf[0]=='q') {
   			 break;
   		 }
		 else if( buf[0]=='r'){
		      genKey(key);
    		      sendKey(ssl, key);
		 }
   	 }
   	 else {
   		 printf("Invalid.\n");
   		 continue;
   	 }
    }
    memset(key, 0, KEYSIZE);
    memset(IV, 0, IVSIZE);
    sendKey(ssl, key);
    sleep(1);
    kill(pid, SIGTERM);
    wait(0);
    SSL_shutdown(ssl);  /* send SSL/TLS close_notify */
    close(fd);
    SSL_free(ssl);
    SSL_CTX_free(ctx);
}
Exemple #8
0
void loadshader::signalname(QString name){
 emit sendName(name);
}