Beispiel #1
0
int main(int argc, char *argv[]) {
    int n = 0;
    int rc =0;
	signal(SIGINT, sighandler);
	int port = PUSHER_USE_SSL==1 ? 443 : 80;
	char *address = PUSHER_USE_SSL==1 ? "ws.pusherapp.com" : "ws.pusherapp.com";

    // #### WARNING ### --> Make sure to modify config.h with your key
    struct PusherConnection *conn = pusherCreate(PUSHER_KEY, NULL);

    conn->eventHandlers = eventHandlers;
    rc = makeConnection(address, port, PUSHER_USE_SSL, conn);
    if (rc < 0)
        return rc;

    pusherStart(conn);

    int i= 0;
    n = 0;
    while (!forceExit && !conn->closed) {
        sleep(1);
    }
    rc = 0;

done:
	fprintf(stderr, "Exiting: %d\n", rc);
    pusherDestroy(conn);
    return rc;
}
Beispiel #2
0
void RhoBluetoothManager::onDiscoverDlgSelectDevice(int index) {
	LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() START";
	if (index < 0) {
		fireCreateSessionCallBack(RHO_BT_CANCEL, "");
		LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() invalid index";
		return;
	}

	// make client connection
	m_pCurrentDevice=m_pStart;
	if (m_pStart == NULL) {
		LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() empty device list";
		fireCreateSessionCallBack(RHO_BT_ERROR, "");
		return;
	}
	for (int iCount = 0 ;(m_pCurrentDevice)&&iCount!=index;m_pCurrentDevice=m_pCurrentDevice->NextDevice,iCount++);
	BT_ADDR bt_addr = m_pCurrentDevice->bthAddress;
	
	if (makeConnection(bt_addr) == 0) {
		// get connected_device_name
		RhoDeviceInfo devInfo;
		GetDeviceInfo(&devInfo, index);
		WideCharToMultiByte(CP_UTF8, 0, devInfo.szDeviceNameAddr, -1, mConnectedDeviceName, MAX_NAME_SIZE, 0, 0);
		// fire callback
		LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() FINISH OK";
		fireCreateSessionCallBack(RHO_BT_OK, mConnectedDeviceName);
		return;
	}
	LOG(INFO)  + "RhoBluetoothManager::onDiscoverDlgSelectDevice() cannot make connection !";

	// fire callback
	fireCreateSessionCallBack(RHO_BT_ERROR, "");
	
}
Beispiel #3
0
LingFu::LingFu()
{
    makeConnection();
    setMyRole(this);

    Button *leiMing,*fengXing,*checkCover;
    leiMing=new Button(3,QStringLiteral("灵符-雷鸣"));
    fengXing = new Button(4,QStringLiteral("灵符-风行"));

    buttonArea->addButton(leiMing);
    buttonArea->addButton(fengXing);
    //buttonArea->addButton(checkCover);
    connect(leiMing,SIGNAL(buttonSelected(int)),this,SLOT(leiMing()));
    connect(fengXing,SIGNAL(buttonSelected(int)),this,SLOT(fengXing()));

    checkCover = new Button(10,QStringLiteral("查看妖力"));
    buttonArea->addOutsideTurnButton(checkCover);

    checkCover->setVisible(true);
    checkCover->setEnabled(true);
    connect(checkCover,SIGNAL(buttonSelected(int)),gui,SLOT(showCoverArea()));
    connect(checkCover,SIGNAL(buttonUnselected(int)),gui,SLOT(closeCoverArea()));


}
Beispiel #4
0
LingHun::LingHun()
{

    makeConnection();
    setMyRole(this);
    lianJieUsed=false;
    Button *linghunzhaohuan;
    linghunzhaohuan=new Button(3,"灵魂召还");
    buttonArea->addButton(linghunzhaohuan);
    connect(linghunzhaohuan,SIGNAL(buttonSelected(int)),this,SLOT(LingHunZhaoHuan()));

    Button *linghunjingxiang;
    linghunjingxiang=new Button(4,"灵魂镜像");
    buttonArea->addButton(linghunjingxiang);
    connect(linghunjingxiang,SIGNAL(buttonSelected(int)),this,SLOT(LingHunJingXiang()));

    Button *linghunzhenbao;
    linghunzhenbao=new Button(5,"灵魂震爆");
    buttonArea->addButton(linghunzhenbao);
    connect(linghunzhenbao,SIGNAL(buttonSelected(int)),this,SLOT(LingHunZhenBao()));

    Button *linghunciyu;
    linghunciyu=new Button(6,"灵魂赐予");
    buttonArea->addButton(linghunciyu);
    connect(linghunciyu,SIGNAL(buttonSelected(int)),this,SLOT(LingHunCiYu()));
}
Beispiel #5
0
void Node::connect(int output, std::shared_ptr<Node> toNode, int input) {
	if(doesEdgePreserveAcyclicity(std::static_pointer_cast<Node>(this->shared_from_this()), toNode) == false) ERROR(Lav_ERROR_CAUSES_CYCLE, "Connection would cause infinite loop.");
	auto outputConnection =getOutputConnection(output);
	auto inputConnection = toNode->getInputConnection(input);
	makeConnection(outputConnection, inputConnection);
	simulation->invalidatePlan();
}
Beispiel #6
0
void ElogThreadSubmit::run( ) {
  int status, sock, error;
  
  error = makeConnection( &sock, &status );
  if( status == 0 ) {
    doTransmit( sock );
    close( sock );
  }
  else {
    switch( error ) {
      case -1:
        doError( tr2i18n("Failed to add ELOG entry: failed to connect to host.") );          	      		  break;
      case -2:
        doError( tr2i18n("Failed to add ELOG entry: failed to get host name.") );          	      		  break;
      case -3:
        doError( tr2i18n("Failed to add ELOG entry: failed to create socket.") );
        break;
      case -4:
        doError( tr2i18n("Failed to add ELOG entry: failed to get host by address.") );
        break;
      case -5:
        doError( tr2i18n("Failed to add ELOG entry: failed to get host by name.") );          	      		  break;
      default:
        doError( tr2i18n("Failed to add ELOG entry: unknown error.") );
        break;
    }
  }
}
Beispiel #7
0
// Server loop to handle incoming messages
void UDPServer::loop(){
    std::unique_lock<std::mutex> connectionLock(_mutex, std::defer_lock);
    sockaddr client_addr;      // IP & port of other end of connection
    unsigned int client_size;
    char c; 
    std::string str="";
    const char *term=" \t\r\n";
    while (!_dead) {
	    if(skt_recvN_from(_socket,&c,1,&client_addr, &client_size) != 0){
	        stop(); // Stop on error
	    }
	    if (strchr(term,c)) {
		    if (c=='\r') continue; /* will be CR/LF; wait for LF */
		    else{
		        connectionLock.lock();
		        
		        // Create connection if needed
		        if(_connections.count(to_string(client_addr)) == 0){
		            std::shared_ptr<UDPConnection> newCon = makeConnection(_socket, client_addr);
		            newCon -> start();
		            _connections[to_string(client_addr)] = newCon;
		        }
		        
		        // Push the message to the connection for handling
		        ((UDPConnection*)(_connections[to_string(client_addr)].get())) -> push(str);
		        
		        connectionLock.unlock();
		    }
	    }
	    else str+=c; /* normal character--add to string and continue */
    }
}
/************************************************************************
 * int room_index	Identifies the room to add connection(s) to.
 * char* rooms[]	Array of room names, each to correspond to a file.
 * int connections	Total number of connections the room 
 * 			identified by room_index should have.
 ***********************************************************************/
void initRoom(int room_index, char* rooms[], int connections, char* directory ) {
	char *room_name = rooms[room_index];
	FILE *file_p = NULL;
	// need to open in directory, so craft the string here
	char room_dir[100] = "";
	strcat_safe( room_dir, 100, directory );
	strcat_safe( room_dir, 100, "/" );
	strcat_safe( room_dir, 100, rooms[room_index] );

	file_p = fopen( room_dir, "a+" );
	// Check for successful file opening.
	if ( ! file_p ) {
		printf( "Error opening file in function initRoom!\n" );
		exit( 1 );
	}

	int connections_in_file = countConnections( file_p );
	int connections_to_make = connections - connections_in_file;

	while ( connections_to_make > 0 ) {
		int rand_index = randInRange( 0, 6 );
		if ( makeConnection( room_index, rand_index, rooms, directory, file_p ) ) {
			connections_to_make--;
		}
	}

	fclose(file_p);
}
void ossimQtVceCanvasWidget::contentsMouseReleaseEvent(QMouseEvent * e )
{
   theMouseButtonState = e->button();
   
   switch(e->button())
   {
   case Qt::LeftButton:
   {
      if(theSelectionRect)
      {
         QCanvasItemList collisionList = theSelectionRect->collisions(true);
         selectItems(collisionList);
         deleteSelectionRect();
      }
      else if(theLineObject)
      {
        ossimQtVceShapeRect  startRect(QRect(theLineObject->startPoint().x(),
                                             theLineObject->startPoint().y(),
                                             1,
                                             1),
                                       canvas());
        ossimQtVceShapeRect  endRect(QRect(theLineObject->endPoint().x(),
                                           theLineObject->endPoint().y(),
                                           1,
                                           1),
                                     canvas());
        
         // make sure that the selection rect is in front of everything
         //
         startRect.setZ(1);
         endRect.setZ(1);
         
         QCanvasItemList startList = startRect.collisions(true);
         QCanvasItemList endList   = endRect.collisions(true);
         QPoint startPt            = theLineObject->startPoint();
         QPoint endPt              = theLineObject->endPoint();
         
         ossimQtVceConnectableObject* startObj = getObjectWhereConnectableSlotIntersectsPoint(startList,
                                                                                              startPt);
         ossimQtVceConnectableObject* endObj   = getObjectWhereConnectableSlotIntersectsPoint(endList,
                                                                                              endPt);
         if(startObj&&endObj)
         {
            makeConnection(startObj, startPt, endObj, endPt);
         }
         delete theLineObject;
         theLineObject = NULL;
      }
      break;
   }
   default:
     {
       break;
     }
   }
   theMouseButtonState = Qt::NoButton;      
   emit canvasWidgetMouseReleaseEvent(e);
}
Beispiel #10
0
void Node::connectProperty(int output, std::shared_ptr<Node> node, int slot) {
	if(doesEdgePreserveAcyclicity(std::static_pointer_cast<Node>(this->shared_from_this()), node) == false) ERROR(Lav_ERROR_CAUSES_CYCLE, "Connection would cause infinite loop.");
	auto &prop = node->getProperty(slot);
	auto conn = prop.getInputConnection();
	if(conn ==nullptr) ERROR(Lav_ERROR_CANNOT_CONNECT_TO_PROPERTY, "Property does not support connections.");
	auto outputConn =getOutputConnection(output);
	makeConnection(outputConn, conn);
	simulation->invalidatePlan();
}
void Logic::destroyRoom(){
    network::LeaveRoomRequest* leave = new network::LeaveRoomRequest();
    socket->sendMessage(network::MSG_LEAVE_ROOM_REQ, leave);
    disconnect(socket, 0, this, 0);
    makeConnection();
    if(myRole){
        delete myRole;
        myRole = NULL;
    }
}
Beispiel #12
0
YongZhe::YongZhe()
{
    makeConnection();
setMyRole(this);

    Button *tiaoXin;
    tiaoXin=new Button(3,QStringLiteral("挑衅"));
    buttonArea->addButton(tiaoXin);
    connect(tiaoXin,SIGNAL(buttonSelected(int)),this,SLOT(TiaoXin()));
}
Beispiel #13
0
void GraphData::addEdge( Packet p )
{
	uint32_t ipA = p.getSourceAddress();
	uint32_t ipB = p.getDestinationAddress();
	uint32_t weight = p.getActualSize();

	Connections connection = makeConnection( p );

	graphMapMutex_.lock();
	if( graphMap_[ipA][ipB] == NULL )
	{
		//new edge
		graphMap_[ipA][ipB] = new GraphInfo;
		graphMap_[ipA][ipB]->lastAccess = time( NULL );
		graphMap_[ipA][ipB]->weights[0] = weight;
		graphMap_[ipA][ipB]->weights[1] = 0;
		graphMap_[ipA][ipB]->weights[2] = 0;
		graphMap_[ipA][ipB]->weights[3] = 0;
		graphMap_[ipA][ipB]->weights[4] = 0;
		graphMap_[ipA][ipB]->weights[5] = 0;
		graphMap_[ipA][ipB]->connections.push_back( connection );
	}
	else
	{
		//already existed
		addConnection( graphMap_[ipA][ipB]->connections, connection );
		time_t currentTime = time(NULL);
		time_t oldAccessTime = graphMap_[ipA][ipB]->lastAccess;
		if( currentTime == oldAccessTime )
		{
			graphMap_[ipA][ipB]->weights[0] += weight;
		}
		else
		{
			uint32_t newWeights[6] = {0,0,0,0,0,0};
			int secondsPass = currentTime - oldAccessTime;
			for(int i = 0; i < 6; ++i )
			{
				int newIndex = secondsPass + i;
				if( newIndex > 5 )
				{
					break;
				}
				newWeights[newIndex] = graphMap_[ipA][ipB]->weights[i];
			}
			for(int i = 0; i < 6; ++i )
			{
				graphMap_[ipA][ipB]->weights[i] = newWeights[i];
			}
		}
		graphMap_[ipA][ipB]->lastAccess = currentTime;
	}
	graphMapMutex_.unlock();
}
Beispiel #14
0
DDTSession*
DDTManager::getSession()
{
    if (mSession!=NULL && mSession->disconnected())
        disconnect(); // Will delete mSession

    if (mSession==NULL)
        mSession = makeConnection(); // If not already connected, make default connection

        return mSession;
}
Beispiel #15
0
int main(int argc, const char * argv[]) {
    if(argc != 2){
        std::cerr << "Requires two arguments." << std::endl;
        exit(-1);
    }
    int port = atoi(argv[1]);
    int cli;
    makeConnection(cli, port);
    getData(cli);
    close(cli);
    return 0;
}
bool ossimQtVceCanvasWidget::addDataManagerObject(ossimConnectableObject* obj,
                                                  const QPoint& position)
{
   bool result = false;
   QPoint currentPosition = position;
   ossimImageChain* chain = PTR_CAST(ossimImageChain, obj);
   if(chain)
   {
      int numberOfObjects = chain->getNumberOfObjects(false);
      int idx = 0;
      if(numberOfObjects == 1)
      {
          addObject((ossimConnectableObject*)(*chain)[idx]->dup(),
                    currentPosition);
      }
      else
      {
         ossimConnectableObject* startObj  = (ossimConnectableObject*)(*chain)[numberOfObjects-1]->dup();
         ossimConnectableObject* endObj    = (ossimConnectableObject*)NULL;
         QCanvasItem* endObjVce   = (QCanvasItem*)NULL;
         QCanvasItem* startObjVce = addObject(startObj,
                                              currentPosition);

         for(idx = numberOfObjects-1; idx > 0; --idx)
         {
            endObj = (ossimConnectableObject*)(*chain)[idx-1]->dup();
            
            if(endObj)
            {
               endObjVce = addObject(endObj,
                                     QPoint(currentPosition.x() + 80,
                                            currentPosition.y()));
               currentPosition.setX(currentPosition.x() + 80);
               if(startObjVce&&endObjVce)
               {
                  ossimQtVceShape* shape1 = ossimQtVceShape::castToVceShape(startObjVce);
                  ossimQtVceShape* shape2 = ossimQtVceShape::castToVceShape(endObjVce);

                  if(shape1->castToConnectable()&&
                     shape2->castToConnectable())
                  {
                     makeConnection((ossimQtVceConnectableObject*)shape1,
                                    (ossimQtVceConnectableObject*)shape2);
                  }
               }
            }
            startObjVce = endObjVce;
         }
      }
      result = true;
   }
   return result;
}
/* DEPS:
 * Global: nameList, NUM_SERVERS
 */
int* initReduce(){
  // make an array for all of our sockets
  int sockIDs[NUM_SERVERS];
  int i;

  // setup all the sockets we need
  for (i = 0; i < NUM_SERVERS; i++){
    sockIDs[i] = openSocket();
    printf("connecting.... %s\n", nameList[i]);
    makeConnection(sockIDs[i], nameList[i], PORT);
  }
  return sockIDs;
}
JianDi::JianDi()
{
    makeConnection();
    setMyRole(this);

    Button *checkCover;
    checkCover = new Button(10,QStringLiteral("查看剑魂"));
    buttonArea->addOutsideTurnButton(checkCover);

    checkCover->setVisible(true);
    checkCover->setEnabled(true);
    connect(checkCover,SIGNAL(buttonSelected(int)),gui,SLOT(showCoverArea()));
    connect(checkCover,SIGNAL(buttonUnselected(int)),gui,SLOT(closeCoverArea()));
}
Beispiel #19
0
void toNewConnection::done(int r)
{
    if (r == QDialog::Rejected)
    {
        QDialog::done(r);
        return;
    }

    NewConnection = makeConnection(true);
    if (!NewConnection)
        return;

    writeSettings();
    QDialog::done(r);
}
ZhongCai::ZhongCai()
{
    makeConnection();
    setMyRole(this);

    Button *moRiShenPan;
    moRiShenPan=new Button(3,QStringLiteral("末日审判"));
    buttonArea->addButton(moRiShenPan);
    connect(moRiShenPan,SIGNAL(buttonSelected(int)),this,SLOT(MoRiShenPan()));

    Button *panJueTianPing;
    panJueTianPing=new Button(4,QStringLiteral("判决天平"));
    buttonArea->addButton(panJueTianPing);
    connect(panJueTianPing,SIGNAL(buttonSelected(int)),this,SLOT(PanJueTianPing()));
}
Beispiel #21
0
XianZhe::XianZhe()
{
    makeConnection();
    setMyRole(this);

    Button *moDaoFaDian;
    moDaoFaDian=new Button(3,"魔道法典");
    buttonArea->addButton(moDaoFaDian);
    connect(moDaoFaDian,SIGNAL(buttonSelected(int)),this,SLOT(MoDaoFaDian()));

    Button *shengJieFaDian;
    shengJieFaDian=new Button(4,"圣洁法典");
    buttonArea->addButton(shengJieFaDian);
    connect(shengJieFaDian,SIGNAL(buttonSelected(int)),this,SLOT(ShengJieFaDian()));
}
Beispiel #22
0
/***************************************************************************************
 *
 * PUBLIC METHOD: StartServer
 *
 **************************************************************************************/
int CTcpServer::StartServer( char* aLocalInterface, char* aLocalPort )
{	
	int r;
	r =initialise();
 
	if(r != ITS_OK)
		return r;

	r = setArguments( aLocalInterface, aLocalPort );
	if(r != ITS_OK)
		return r;
	
	r = makeConnection(iLocal_Sock, iRemote_Sock, iRemote_Addr);
	return r;
	
}
Beispiel #23
0
ShengNv::ShengNv()
{
    makeConnection();
    Button *zhiLiaoShu, *zhiYuZhiGuang, *shengLiao;
    zhiLiaoShu = new Button(3,tr("治疗术"));
    buttonArea->addButton(zhiLiaoShu);
    connect(zhiLiaoShu,SIGNAL(buttonSelected(int)),this,SLOT(ZhiLiaoShu()));

    zhiYuZhiGuang=new Button(4, tr("治愈之光"));
    buttonArea->addButton(zhiYuZhiGuang);
    connect(zhiYuZhiGuang,SIGNAL(buttonSelected(int)),this,SLOT(ZhiYuZhiGuang()));

    shengLiao=new Button(5,tr("圣 疗"));
    buttonArea->addButton(shengLiao);
    connect(shengLiao,SIGNAL(buttonSelected(int)),this,SLOT(ShengLiao()));
}
ShengQiang::ShengQiang()
{
    makeConnection();
	setMyRole(this);
    Button *huiYao, *chengJie, *shengGuangQiYu;
    huiYao = new Button(3,QStringLiteral("辉耀"));
    buttonArea->addButton(huiYao);
    connect(huiYao,SIGNAL(buttonSelected(int)),this,SLOT(HuiYao()));

    chengJie = new Button(4,QStringLiteral("惩戒"));
    buttonArea->addButton(chengJie);
    connect(chengJie,SIGNAL(buttonSelected(int)),this,SLOT(ChengJie()));

    shengGuangQiYu = new Button(5,QStringLiteral("圣光祈愈"));
    buttonArea->addButton(shengGuangQiYu);
    connect(shengGuangQiYu,SIGNAL(buttonSelected(int)),this,SLOT(ShengGuangQiYu()));
}
Beispiel #25
0
// Server loop to handle incoming connections
void TCPServer::loop(){
    std::unique_lock<std::mutex> connectionLock(_mutex, std::defer_lock);
    while(!_dead){
        skt_ip_t client_ip;      // IP & port of other end of connection
        unsigned int client_port;
        
        int cSocket = skt_accept(_socket, &client_ip, &client_port);
        sockaddr_in address = skt_build_addr(client_ip, client_port);
        sockaddr client_addr = *((sockaddr *)(&address));
        
        connectionLock.lock();
        std::shared_ptr<TCPConnection> newCon = makeConnection(cSocket, client_addr);
        newCon -> start();
        _connections[to_string(client_addr)] = newCon;
        connectionLock.unlock();
    }
}
Beispiel #26
0
int main()
{
	
	//ONCE VEHICLE DEGER ATA
	Vehicle vehicle;
	State state[4];
	
	state[0]=0;
	state[1]=1;
	state[2]=0;
	state[3]=1;
	
	char *name="audi";
	
	setVehicleName(&vehicle,name);
	setVehicleTemp(&vehicle, 1.0,2.0,3.5);
	setVehicleSpeed(&vehicle, 45);
	setVehicleDoor(&vehicle, state[0], state[1], state[2], state[3]);
	setVehicleWheelPressure(&vehicle, 25,30,30,25);
	
	printf("----------------------------------------------------\n");
	printf("Applied Vehicle Properties:\n");
	printf("----------------------------------------------------\n");
	printf("Name: %s\n",vehicle.name);
	printf("Speed: %d\n",vehicle.speed);
	printf("Temperature: (motor) %d , (indoor) %d , (outdoor) %d\n",vehicle.Temp.motor,vehicle.Temp.indoor,vehicle.Temp.outdoor);
	printf("Door: (frontLeft) %d ,(frontRight) %d,(rearLeft) %d,(rearRight) %d\n",vehicle.Door.frontLeft, vehicle.Door.frontRight,vehicle.Door.rearLeft, vehicle.Door.rearRight);
	printf("Wheel Pressure : (frontLeft) %d ,(frontRight) %d ,(rearLeft) %d, (rearRight) %d\n",vehicle.WheelPressure.frontLeft,vehicle.WheelPressure.frontRight,vehicle.WheelPressure.rearLeft,vehicle.WheelPressure.rearRight);
	printf("----------------------------------------------------\n");
	
	printf("open the server\n\n");
	
	int server, port,client;
	port=7777;
	if(initializeConnection(&server,port))
	{
		while(1)
		{
			client=makeConnection(&server);
			
			if(answerMessage(client,&vehicle));
		}
	}

return 0;
}	
Beispiel #27
0
MaoXian::MaoXian()
{
    makeConnection();
    connect(playerArea,SIGNAL(playerUnready()),this,SLOT(onUnready()));

    Button *qiZha,*touTianHuanRi,*teShuJiaGong;
    qiZha=new Button(3,tr("欺 诈"));
    buttonArea->addButton(qiZha);
    connect(qiZha,SIGNAL(buttonSelected(int)),this,SLOT(QiZha()));

    touTianHuanRi=new Button(4,tr("偷天换日"));
    buttonArea->addButton(touTianHuanRi);
    connect(touTianHuanRi,SIGNAL(buttonSelected(int)),this,SLOT(TouTianHuanRi()));

    teShuJiaGong=new Button(5,tr("特殊加工"));
    buttonArea->addButton(teShuJiaGong);
    connect(teShuJiaGong,SIGNAL(buttonSelected(int)),this,SLOT(TeShuJiaGong()));
}
MoGong::MoGong()
{
    makeConnection();
    setMyRole(this);

    Button *leiGuangSanShe, *checkCover;

    leiGuangSanShe=new Button(3,QStringLiteral("雷光散射"));
    buttonArea->addButton(leiGuangSanShe);
    connect(leiGuangSanShe,SIGNAL(buttonSelected(int)),this,SLOT(LeiGuangSanShe()));

    checkCover = new Button(10,QStringLiteral("查看充能"));
    buttonArea->addOutsideTurnButton(checkCover);
    checkCover->setVisible(true);
    checkCover->setEnabled(true);
    connect(checkCover,SIGNAL(buttonSelected(int)),gui,SLOT(showCoverArea()));
    connect(checkCover,SIGNAL(buttonUnselected(int)),gui,SLOT(closeCoverArea()));
}
void MainWindow::tryConnect(){

    // If there has been any connection, close it first
    if( this->socket > 0 ){
        qDebug() << "Make the connection again";
        this->keepAlive->stop();
        request.system(System::Request_Operation_QuitGame, [this](Model::Reply* reply){});

        QThread::sleep(1);

        this->socket = -1;
        makeConnection();
        qDebug() << "Quit the game";

    }
    else{
        this->makeConnection();
    }
}
FengYin::FengYin()
{
    makeConnection();
    setMyRole(this);
    connect(playerArea,SIGNAL(playerUnready()),this,SLOT(onUnready()));
//新建技能按钮
    Button *fengYinFaShu,*wuXiShuFu,*fengYinPoSui;
    fengYinFaShu=new Button(3,QStringLiteral("封印法术"));
    buttonArea->addButton(fengYinFaShu);
    connect(fengYinFaShu,SIGNAL(buttonSelected(int)),this,SLOT(FengYinFaShu()));

    wuXiShuFu=new Button(4,QStringLiteral("五系束缚"));
    buttonArea->addButton(wuXiShuFu);
    connect(wuXiShuFu,SIGNAL(buttonSelected(int)),this,SLOT(WuXiShuFu()));

    fengYinPoSui=new Button(5,QStringLiteral("封印破碎"));
    buttonArea->addButton(fengYinPoSui);
    connect(fengYinPoSui,SIGNAL(buttonSelected(int)),this,SLOT(FengYinPoSui()));
}