コード例 #1
0
ファイル: main.cpp プロジェクト: chaot4/sea-crossing
int main(){

	Conf conf("config");
	conf.readFromFile();

	MessageReceiver *testReceiver;
	RenderHub testRenderer(testReceiver);
	//if(testRenderer.init())
	//{
	//	testRenderer.addScene();
	//	testRenderer.setActiveScene(0);
	//	testReceiver->pushLoadSceneMessages();
	//	std::thread renderThread(&RenderHub::run,&testRenderer);
	//}
	std::thread renderThread(&RenderHub::init,&testRenderer);
	testReceiver->pushLoadSceneMessages();
	
	Board board;
	RandomAIPlayer player1(conf.getGameConf().p1_name, board);
	ShortestPathAIPlayer<Cost, Rating> player2(conf.getGameConf().p2_name, board);
	
	SimpleGUIGame g(&player1, &player2, board, conf.getGameConf(), testReceiver);
	std::thread gameThread(&SimpleGUIGame::start,&g);

	gameThread.join();
	renderThread.join();
}
コード例 #2
0
ファイル: Message.cpp プロジェクト: chrizzoy/yate
bool MessageRelay::receivedInternal(Message& msg)
{
    MessageReceiver* receiver = m_receiver;
    int id = m_id;
    safeNow();
    return receiver && receiver->received(msg,id);
}
コード例 #3
0
ファイル: TestClient.cpp プロジェクト: korwe/the-core-cpp
int handleService(ServiceRequest& req, MessageSender& sender, MessageReceiver& receiver, MessageReceiver& dataReceiver) {
    sender.sendCoreMessage(req, SESSION_ID);
    ServiceResponse* serviceResponse = dynamic_cast<ServiceResponse*>(receiver.getNextCoreMessage(1500));
    if (serviceResponse == 0) {
        std::cout << "Failure: No response to service request" << std::endl;
        return 1;
    }
    if (serviceResponse->isSuccessful()) {
            std::cout << "Request successful" << std::endl;
        if (serviceResponse->hasData()) {
            std::cout << "Response has associated data" << std::endl;
            DataResponse* dataResponse = dynamic_cast<DataResponse*>(dataReceiver.getNextCoreMessage(1500));
            if (dataResponse == 0) {
                std::cout << "Failure: Associated data not available" << std::endl;
                return 1;
            }
            std::cout << "Response data: " << dataResponse->data() << std::endl;
            delete dataResponse;
        }
    }
    else {
        std::cout << "Request unsuccessful" << std::endl;
        std::cout << "Error code: " << serviceResponse->errorCode() << std::endl;
        std::cout << "Error message: " << serviceResponse->errorMessage() << std::endl;
    }
    delete serviceResponse;
    return 0;
}
コード例 #4
0
void MessageReceiverMap::addMessageReceiver(StringReference messageReceiverName, MessageReceiver& messageReceiver)
{
    ASSERT(!m_globalMessageReceivers.contains(messageReceiverName));

    messageReceiver.willBeAddedToMessageReceiverMap();
    m_globalMessageReceivers.set(messageReceiverName, &messageReceiver);
}
コード例 #5
0
void MessageReceiverMap::addMessageReceiver(StringReference messageReceiverName, uint64_t destinationID, MessageReceiver& messageReceiver)
{
    ASSERT(destinationID);
    ASSERT(!m_messageReceivers.contains(std::make_pair(messageReceiverName, destinationID)));
    ASSERT(!m_globalMessageReceivers.contains(messageReceiverName));

    messageReceiver.willBeAddedToMessageReceiverMap();
    m_messageReceivers.set(std::make_pair(messageReceiverName, destinationID), &messageReceiver);
}
コード例 #6
0
ファイル: MessageReceiver.cpp プロジェクト: nixz/covise
void *MessageReceiver::receiveLoop(void *messageReceiver)
#endif
{

    MessageReceiver *mr = (MessageReceiver *)messageReceiver;

    while (1)
    {
        mr->_waitForConnection();
        while (1) //while (mr->_receiveData() != -1)
        {
            mr->_receiveData();
            mr->_sendData();
        }
        mr->_disconnect();
    }

#ifndef _WIN32
    return NULL;
#endif
}
コード例 #7
0
void readMessage(){
  switch(receiver.getMessageType()){
  case CLEAR_MESSAGE:
    printf("clear\n");
    break;
  case FOLLOW_MODE_MESSAGE:
    follow = receiver.getMessageData()[0] & 0x0f;
    printf("follow %d\n", follow);
    break;
  case SET_LED_MESSAGE:
    if(follow){
      holding = receiver.getMessageData()[2];
      holdRow = receiver.getMessageData()[1] / COLS;
      holdCol = receiver.getMessageData()[1] % COLS;
      printf("holding %d %d 0x%x\n", holdCol, holdRow, holding);
    }else{
      uint8_t row = receiver.getMessageData()[1] / COLS;
      uint8_t col = receiver.getMessageData()[1] % COLS;
      uint8_t brt = receiver.getMessageData()[2];
      printf("led %d %d 0x%x\n", col, row, brt);
    }
    break;
  }
}
コード例 #8
0
int main(void)
{
  while(serialAvailable())
    if(receiver.receiveMessage())
      readMessage();
}
コード例 #9
0
TEST(MessageReceiver_test, testUninitializedListen) {
    MessageReceiver r;
    bool successful_listen = r.listen(); // but need to init() first!
    EXPECT_FALSE(successful_listen);
}
コード例 #10
0
TEST(MessageReceiver_test, testBadSocketFilename) {
    MessageReceiver r;
    auto cb = [](uint32_t, const char*, uint32_t) {};
    bool initialized = r.init("/sys/socket_filepath", cb);
    EXPECT_FALSE(initialized);
}
コード例 #11
0
ファイル: SetupMessage.cpp プロジェクト: Ethax/PiTempControl
/*
 * Átadja az ebbõl az osztályból példányosított objektumot az
 * üzenetet fogadó objektumnak feldolgozásra.
 */
void SetupMessage::send(MessageReceiver & receiver) const {
	receiver.receiveMessage(*this);
}