Esempio n. 1
0
void NVEventQueue::DoneWithEvent(bool ret)
{
  // We only care about blockers for now.
  // All other events just NOP
  pthread_mutex_lock(&m_accessLock);
  if (m_blockerState == PROCESSING_BLOCKER)
  {
    m_blockerReturnVal = ret;
    m_blockerState = RETURNED_BLOCKER;
    broadcast(&m_blockerSync);
  }
  pthread_mutex_unlock(&m_accessLock);
}
Esempio n. 2
0
  void network_module::subthread_routine() {
    const chrono::milliseconds framerate{m_animation_packetloss->framerate()};
    const auto dur = chrono::duration<double>(framerate);

    while (running()) {
      if (m_connected && m_packetloss) {
        broadcast();
      }
      sleep(dur);
    }

    m_log.trace("%s: Reached end of network subthread", name());
  }
Esempio n. 3
0
		virtual void compute(VertexID agg_msg, vector<VertexID>& edges)
		{
			if(step_num()==1)
			{
				VertexID min = id;
				for (int i = 0; i < edges.size(); ++ i) 
				{
					if (min > edges[i]) min = edges[i];
				}
				value = min;
				broadcast(edges);
			}
			else
			{
                if (agg_msg < value)
                {
                    value = agg_msg;
                    broadcast(edges);
                }
			}
			vote_to_halt();
		}
Esempio n. 4
0
    void broadcastTextMessageToAll(Message& message, ClientDesc client)
    {
        message.setClientSource(client.descriptor);
        if(isClientAbleToBroadcastMessage(client.descriptor))
        {
            broadcast(message); 
        }
        else
        {
            std::cout << "Client: " << client.descriptor << " can't broadcast messages due to certificate name restrictions." << std::endl;
        }

    }
Esempio n. 5
0
void Network::sendRoundPadTextMessage(const RoundPad* pad)
{
  // Utility data structures
  char buffer[1024];
  osc::OutboundPacketStream ps(buffer, 1024);

  ps << osc::BeginMessage("/object/pad/text")
     << osc::Symbol(pad->getUuid())
     << osc::Symbol(pad->getCommentText()->getText().c_str())
     << osc::EndMessage;

  broadcast(ps);
}
Esempio n. 6
0
		bool Socket::broadcast(bool enabled){
			bool ret;
			int val;
			ret = broadcast();
			if(enabled == false){
				val = 0;
			}
			else{
				val = 1;
			}
			setsockopt(SOL_SOCKET, SO_BROADCAST, (const void *)&val, (socklen_t)sizeof(int));
			return ret;
		}
Esempio n. 7
0
void CowichanMPI::life(BoolMatrix matrixIn, BoolMatrix matrixOut)
{
  int i;                   // iteration index
  index_t r;               // row index
  int alive;               // number alive
  index_t lo, hi;          // work controls
  index_t rlo, rhi;        // for broadcast
  bool work;               // useful work to do?
  int is_alive = 1;        // some cells still alive?
  BoolMatrix m_tmp;        // tmp pointer

  // work
  work = get_block (world, 0, nr, &lo, &hi);
  for (i = 0; (i < lifeIterations) && (is_alive > 0); i++) {
  
    // reset alive neighbour count
    alive = 0;

    // count neighbours and fill new matrix
    if (work) {
      for (r = lo; r < hi; r++) {
        for (index_t c = 0; c < nc; ++c) {
          index_t count = sumNeighbours(matrixIn, r, c, nr, nc);
          if (count == 3 || ((count == 2) && MATRIX_RECT(matrixIn, r, c))) {
          MATRIX_RECT(matrixOut, r, c) = true;
          ++alive;
        } else {
          MATRIX_RECT(matrixOut, r, c) = false;
        }
        }
      }
    }
    
    // broadcast matrix
    for (r = 0; r < world.size (); r++) {
      if (get_block (world, 0, nr, &rlo, &rhi, r)) {
        broadcast (world, &MATRIX_RECT(matrixOut, rlo, 0),
            (int)((rhi - rlo) * nc), (int)r);
      }
    }
    
    // is_alive is maximum of local alive's
    all_reduce (world, alive, is_alive, mpi::maximum<int>());

  // swap matrices (ping-pong)
    m_tmp = matrixIn;
    matrixIn = matrixOut;
    matrixOut = m_tmp;
    
  }
}
Esempio n. 8
0
  void instance::on_charge(const Event& evt) {
    // verify the existence of the unit and that its the owner's turn
    if (!evt.hasProperty("UID"))
      return;

    bool valid = true;
    Unit *_unit = 0;
    try {
      _unit = active_puppet_->getUnit(convertTo<int>(evt.getProperty("UID")));
    } catch (invalid_uid &e) {
      valid = false;
    }

    std::cout
      << "attempting to find unit with UID : " << evt.getProperty("UID")
      << " and active puppet " << active_puppet_->getUID() << "#" << active_puppet_->getName()
      << " has: \n";
    for (auto unit : active_puppet_->getUnits())
      std::cout << "\t+" << unit->getUID() << "#" << unit->getName() << "\n";


    if (!valid) {
      log_->errorStream() << "invalid charge attempt, uid: " << evt.getProperty("UID");
      return;
    }

    //assert(valid); // __DEBUG__

    // make sure the unit is not resting
    valid = !_unit->isResting();

    assert(valid); // __DEBUG__

    if (_unit->getBaseAP() <= 0)
      return;

    // finally make sure the unit has not already been flagged for attacking
    // (this really shouldn't happen)
    if (!attackers_.empty())
      for (Unit* unit : attackers_)
        assert(unit != _unit);

    attackers_.push_back(_unit);

    Event e(EventUID::Charge, EventFeedback::Ok);
    e.setProperty("UID", _unit->getUID());
    broadcast(e);

    log_->debugStream() << _unit->getUID() << _unit->getName() << " is charging";
  }
Esempio n. 9
0
t_client	*check_egg(t_server *server, t_client *client)
{
  t_client	*egg;
  char		*s;

  if ((egg = get_client_egg_by_team(server->clients, client->team)) != NULL)
    {
      asprintf(&s, "eht #%d\n", egg->socket);
      broadcast(server->clients, s, FD_GRAPHIC);
      free(s);

      asprintf(&s, "ebo #%d\n", egg->socket);
      broadcast(server->clients, s, FD_GRAPHIC);
      free(s);

      client->player = egg->player;
      server->clients = pop_client(server->clients, egg->socket);
    }
  else
    create_player(server, client);

  return (server->clients);
}
Esempio n. 10
0
double fields_chunk::peek_field(component c, const vec &where) {
  double w[8];
  ivec ilocs[8];
  gv.interpolate(c,where, ilocs, w);
  if (gv.contains(ilocs[0]) && f[c][0]) {
    double hello = 0.0;
    if (is_mine()) hello = f[c][0][gv.index(c,ilocs[0])];
    broadcast(n_proc(), &hello, 1);
    return hello;
  }
  //abort("Got no such %s field at %g %g!\n",
  //      component_name(c), gv[ilocs[0]].x(), gv[ilocs[0]].y());
  return 0.0;
}
Esempio n. 11
0
int flood_linkstate(struct routes* route_list, struct memberList* member_list) {
  //lock here
  pthread_mutex_lock(&(member_list->lock));
  struct AddressInfo source;

  struct linkstate_packet* lstate_pack;

  create_linkstate_packet(member_list, &source, lstate_pack);
  broadcast(route_list, lstate_pack);
  pthread_mutex_unlock(&(member_list->lock));

  return 0;

}
Esempio n. 12
0
	void hdlc16::insert_bit( bool bit )
	{
	assert( bit == 0 || bit == 1 );

	last_8_bits = ( last_8_bits << 1 ) | ( bit & 1 );

	if( num_contig_ones == 5 && bit == 0 )
		{
		/*skip stuffed bit*/
		}
	else
		{
		if( bitlocked )
			{
			bitbuf.push_back( bit );
			if( bitbuf.size() > 24 )
				{
				//only insert from 24 bits back
				//this skips the frame CRC(16bit),
				//and skips the end framer byte(8bit)
				crc.insert( bitbuf[ bitbuf.size() - 25 ] );
				}
			}

		if( valid_frame() )
			{
			frames::frame frame = emit_frame();
			frames::buffer buffer;

			buffer.push_back( frame );

			broadcast( buffer );
			}

		if( last_8_bits == HDLC_FRAMER )
			{
			bitbuf.clear();
			bitlocked = true;
			}
		}

	if( bit == 1 )
		{
		num_contig_ones++;
		}
	else
		{
		num_contig_ones = 0;
		}
	}
Esempio n. 13
0
void sc_son_body_model1(xsim_t *xsim, int node_id)
{
    /* Initialize xsim */
    xsim_node_t      *node                   = NULL;
    xsim_msg_list_t **to_send                = NULL;
    sim_time          next_time_for_resource = 0;
    sim_time          last_time_broadcast    = 0;
    int               stabilized             = 0;

	xsim_time_model_init_son_body(xsim, node_id, &node, &to_send);

    next_time_for_resource = is.simulation_time;

    /* global measure */
    xsim_perf_begin_global_measure(global_processus_time, CLOCK_PROC);
    xsim_perf_begin_global_measure(global_simulation_time, CLOCK_OTHERS);

	/*
	 * Body here
	 */
    while (node->current_time < (unsigned int) is.simulation_time) {

        /* simulate the components of the node */
        if (xsim_time_model_simulate_composant(node, to_send, &next_time_for_resource,
                   &stabilized) == END_OF_SIMULATION)
            goto end_of_simulation;

        /* update the time if possible */
        if (xsim_update_local_time_if_possible(node, stabilized, next_time_for_resource) == 1) {
            if ((last_time_broadcast + TIME_PERIOD >= node->current_time) || (last_time_broadcast == 0)) {
                broadcast(&node->msg_box->mark, node->iface[0], xsim_null_msg);
                last_time_broadcast = node->current_time;
            }
			if (node->current_time > next_time_for_resource) {
				EMSG("<%d> (%"PRIu64" t) Error: jump above the next time the resource should work: %"PRIu64"t\n",
						node->node_id, node->current_time, next_time_for_resource);
			}
			if (node->current_time == next_time_for_resource)
				resource_wake_up();
		} 
    }

end_of_simulation:
    /* global measure */
    xsim_perf_end_global_measure(global_processus_time, CLOCK_PROC);
    xsim_perf_end_global_measure(global_simulation_time, CLOCK_OTHERS);

    xsim_time_model_end_of_simulation(node, to_send, is.measures_output);
    return; 
}
Esempio n. 14
0
boolean JMousePosObj::globalMouseMove(JEvent& e, int x, int y) {
  switch (type) {
    case XPOS: {
      value = x*mask/(JComponent::theRootWindow->width-1);
      break;
    }
    case YPOS: {
      value = y*mask/(JComponent::theRootWindow->height-1);
      break;
    }
  }
  broadcast(0);
  return true;
}
Esempio n. 15
0
/**
 * This function sends a message to clients to notify about state change.
 * SAVE_DATA message is also sent when going down.
 * @param state State that is being activated
 */
static void change_state(dsme_state_t new_state)
{
  if (new_state == DSME_STATE_SHUTDOWN ||
      new_state == DSME_STATE_ACTDEAD  || 
      new_state == DSME_STATE_REBOOT)
  {
      DSM_MSGTYPE_SAVE_DATA_IND save_msg =
        DSME_MSG_INIT(DSM_MSGTYPE_SAVE_DATA_IND);

      dsme_log(LOG_DEBUG, PFIX"sending SAVE_DATA");
      broadcast(&save_msg);
  }

  DSM_MSGTYPE_STATE_CHANGE_IND ind_msg =
    DSME_MSG_INIT(DSM_MSGTYPE_STATE_CHANGE_IND);

  ind_msg.state = new_state;
  dsme_log(LOG_DEBUG, PFIX"STATE_CHANGE_IND sent (%s)", state_name(new_state));
  broadcast(&ind_msg);

  dsme_log(LOG_NOTICE, PFIX"new state: %s", state_name(new_state));
  current_state = new_state;
}
Esempio n. 16
0
void JBSubObj::putResult() {
  JBlock ov = value;
  int dest = end;
  int sz = block.size();
  if (sz > 0) {
    begin = max(0, min(sz-1, begin));
    if (inputSet(IN_END).last()) {
      if (dest < 0) dest = sz;
      else dest = max(begin, min(sz, dest));
    } else dest = begin+1;
    value = block(begin, dest);
  } else value = block;
  if (value != ov) broadcast(0);
}
Esempio n. 17
0
void Monster::diePermCrt() {
    std::map<int, crlasttime>::iterator it;
    crlasttime* crtm=0;
    Monster *temp_mob=0;
    UniqueRoom  *room=0;
    char    perm[80];
    long    t = time(0);
    int     i=0;

    strcpy(perm,getCName());

    if(!inUniqueRoom())
        return;
    room = getUniqueRoomParent();

    for(it = room->permMonsters.begin(); it != room->permMonsters.end() ; it++) {
        crtm = &(*it).second;
        if(!crtm->cr.id)
            continue;
        if(crtm->ltime + crtm->interval > t)
            continue;
        if(!loadMonster(crtm->cr, &temp_mob))
            continue;
        if(temp_mob->getName() == getName()) {
            crtm->ltime = t;
            free_crt(temp_mob);
            break;
        }
        free_crt(temp_mob);
    }

    if(flagIsSet(M_DEATH_SCENE) && !flagIsSet(M_FOLLOW_ATTACKER)) {
        int     fd,n;
        char    tmp[2048], file[80],pName[80];

        strcpy(pName, getCName());
        for(i=0; pName[i]; i++)
            if(pName[i] == ' ')
                pName[i] = '_';

        sprintf(file,"%s/%s_%d", Path::Desc, pName, level);
        fd = open(file,O_RDONLY,0);
        if(fd) {
            n = read(fd,tmp,2048);
            tmp[n] = 0;
            broadcast(nullptr, getRoomParent(), "\n%s", tmp);
        }
        close(fd);
    }
}
Esempio n. 18
0
    void 
    CondVarImpl::syncThreads()
    {

        //! Lock condition variable lock
        beginSynchronized();
        
        int rc = 0;    
        
        //! count threads
        if(_count == 0xFFFFFFFF)
            _count = 0;
        else
        {
            _count++;
        }

        if(_count >= _maxThreads - 1)
        {
            //! Set to highest value before broadcasting
            _count = 0xFFFFFFFF;
            //! Unblock all waiting threads
    #ifdef _WIN32
            rc = broadcast();  
            if(rc == 0)
               printf("Problem while calling broadcast\n");

    #else
            rc = pthread_cond_broadcast(&_condVar);
            PRINT_ERROR_MSG(rc, "Problem while calling pthread_cond_broadcast()");
    #endif // _WIN32

        }
        else
        {
            //! Block on a condition variable
    #ifdef _WIN32
            wait();
    #else
            if(_count < _maxThreads - 1)
            {
                rc = pthread_cond_wait(&_condVar, &_condVarLock);
                PRINT_ERROR_MSG(rc, "Problem while calling pthread_cond_wait()");
            }
    #endif // _WIN32
        }
        
        //! Unlock condition variable lock
        endSynchronized();
    }
Esempio n. 19
0
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
  switch (ev) {
    case MG_EV_WEBSOCKET_HANDSHAKE_DONE: {
      /* New websocket connection. Tell everybody. */
      broadcast(nc, mg_mk_str("++ joined"));
      break;
    }
    case MG_EV_WEBSOCKET_FRAME: {
      struct websocket_message *wm = (struct websocket_message *) ev_data;
      /* New websocket message. Tell everybody. */
      struct mg_str d = {(char *) wm->data, wm->size};
      broadcast(nc, d);
      break;
    }
    case MG_EV_CLOSE: {
      /* Disconnect. Tell everybody. */
      if (is_websocket(nc)) {
        broadcast(nc, mg_mk_str("-- left"));
      }
      break;
    }
  }
}
Esempio n. 20
0
File: pilot.C Progetto: zear/sabre
/**************************************************************
 * Take a good hard look at how much punishment we've taken,  *
 * and get out if it's just too much to take!                 *
 **************************************************************/
int Pilot::damage_check()
{
	if (flight->mods.battle_damage > 0)
	{
		if (flight->mods.battle_damage >= flight->specs->max_damage)
		{
			if (functioning)
			{
				broadcast("Ejecting!",6,getAffiliation(),NULL);
				sound_off("takingfire");
				sound_off("takingflak");
				sound_off("heavydamage");
				sound_on("eject",getAffiliation());
				dbg = "EJECT";
				functioning = 0;
				set_target(NULL);
				SetDeath(1);
			}
			return (1);
		}
		else
		{
			if (flight->mods.battle_damage > new_damage)
			{
				new_damage = flight->mods.battle_damage;
				float d1 = ((float)new_damage) / ((float)flight->specs->max_damage);
				if (target_obj->who_got_me != NULL && target_obj->who_got_me->getType() == GROUND_UNIT_T)
				{
					brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Taking flak: %3.0f%%%%",d1 * 100.0);
					sound_on("takingflak",getAffiliation());
				}
				else
				{
					if (d1 >= 0.75)
					{
						brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Heavy damage: %3.0f%%%%!",d1 * 100.0);
						sound_on("heavydamage",getAffiliation());
					}
					else
					{
						brdcst(sbrPRIORITY_REGULAR,getAffiliation(),"Taking fire %3.0f%%%%",d1 * 100.0);
						sound_on("takingfire",getAffiliation());
					}
				}
			}
		}
	}
	return (0);
}
Esempio n. 21
0
void Scene::addEntity(EntityPtr entity)
{
    entity->_control.agentNo = _move->addAgent(entity->_move.position, entity->_control.collision);

    _entitys.insert(std::make_pair(entity->_state.eid, entity));

    if (entity->_state.avatarID != InvalidServiceID && entity->_state.etype == ENTITY_PLAYER)
    {
        _players[entity->_state.avatarID] = entity;
    }

    LOGD("Scene::addEntity. eid[" << entity->_state.eid << "] aid[" << entity->_state.avatarID << "][" << entity->_state.avatarName
        << "]  modleID=" << entity->_state.modelID << ", camp=" << entity->_state.camp << ", etype=" << entity->_state.etype << ", state=" << entity->_state.state 
        << ", agentNo=" << entity->_control.agentNo  << ", hp=[" << entity->_state.curHP << "/" << entity->_state.maxHP 
        << "], spawnpoint" << entity->_control.spawnpoint<< ", position=" << entity->_move.position);
    AddEntityNotice notice;
    notice.syncs.push_back(entity->getClientSyncData());
    broadcast(notice, entity->_state.avatarID);
    EntityScriptNotice sn;
    sn.controls.push_back(entity->_control);
    sn.skills.push_back(entity->_skillSys);
    broadcast(notice, entity->_state.avatarID);
    onAddEntity(entity);
}
Esempio n. 22
0
void EventDispatcher::processQueue() {
	std::shared_ptr<Event> event;

	while(!events.empty()) {
		if(events.try_pop(event)) {
			broadcast(event);
		}

		switch(event->type) {
			case THREAD_EXIT:
				exit = true;
				break;
		}
	}
}
Esempio n. 23
0
int broadcast_message(Client *client, StringBuffer *msg) {

    // Construct message
    StringBuffer *temp = StringBuffer_construct_n(msg->size);
    StringBuffer_concat(temp, "[");
    StringBuffer_concat(temp, client->name);
    StringBuffer_concat(temp, "]: ");
    StringBuffer_concat(temp, msg->buffer);
    
    // Send message to all clients
    broadcast(temp);
    
    StringBuffer_free(temp);
    return EXIT_SUCCESS;
}
Esempio n. 24
0
  /**
   * Handler for XCB_PROPERTY_NOTIFY events
   */
  void xwindow_module::handle(const evt::property_notify& evt) {
    if (evt->atom == _NET_ACTIVE_WINDOW) {
      update(true);
    } else if (evt->atom == _NET_CURRENT_DESKTOP) {
      update(true);
    } else if (evt->atom == _NET_WM_VISIBLE_NAME) {
      update();
    } else if (evt->atom == _NET_WM_NAME) {
      update();
    } else {
      return;
    }

    broadcast();
  }
Esempio n. 25
0
boolean J1DSliderObj::setValue(int _value) {
  _value = max(getMin(), min(getMax(), _value));
  if (_value != value) {
    value=_value;
    int vmin = getMin();
    int range = getMax()-vmin;
    if (!range) fraction = 0;
    else fraction = double(value-vmin)/range;
    oldf = factor;
    broadcast(0);
    repaint();
    return true;
  }
  return false;
}
Esempio n. 26
0
//Event handlers
Actions::Event Server::changeName(std::string message, Client client)
{
	for(int i = 0; i < clients.size(); i++)
	{
		if(clients.at(i).id == client.id)
		{
			//Position 5 should be the beginning of the next word after "/Name"
			clients.at(i).name = message.substr(6, std::string::npos);
			std::string shout = "[" + std::to_string(clients.at(i).id) + "] has changed their name to " + clients.at(i).name;
			broadcast(Message(shout, -1));
			return Actions::Event::NAME;
		}
	}
	return Actions::Event::SPEAK;
}
Esempio n. 27
0
/*
// Name: talk
// In: c, the client that sent the command.
// 	   tag, the tag sent from the client.
//	   message, the message that the client wants to send.
//	   clients, all clients connected.
// Out: 0
// Purpose: Handles the comman TALK.
*/
int talk(clientconn_t *c, char *tag, char *message, hash *clients) {
	char msg[MAXTOKENSIZE];
	memset(msg,'\0', MAXTOKENSIZE);
	strcpy(msg, "* TALK ");
	if(strstr(c->name, " ")) {
		enquote(c->name);
	}
	strcat(msg, c->name);
	strcat(msg, " ");
	strcat(msg, message);
	broadcast(msg, strlen(msg), c, clients, MSG_TALK);
	client_write(c, tag, strlen(tag));
	client_write(c, " OK TALK completed.\r\n", 21);
	return 0;
}
Esempio n. 28
0
void* controler(void *t)	//control the game's order.
{
	int i, n, j;
	struct msgbuf msg;
	char buf[512], current_user_put_pokers[512], current_round_pokers[512], current_user_claim_pokers[512];
	regist();
	poker_gen();
	poker_sender();
	while(1)
	{
		memset(current_round_pokers, '\0', sizeof(current_round_pokers));
		for(i = 0; i < MAXUSERNUM; i++)
		{
			printf("LOG: controler SEND \"TURN\" TO %d\n", connecter_fd[i]);
			write(connecter_fd[i], "TURN", strlen("TURN"));

			//read the real pokers
			msg = readmsg();	
			strcpy(buf, msg.mtext);
			printf("LOG: %d-----%s\n", msg.mtype, msg.mtext);
			sscanf(buf, "%*s%s", current_user_put_pokers); 		
			printf("LOG: %d CURRENT_USER_PUT_POKERS: %s\n", connecter_fd[i], current_user_put_pokers);
			strcat(current_round_pokers, current_user_put_pokers);
			printf("LOG: %d CURRENT_ROUND_POKERS: %s\n", connecter_fd[i], current_round_pokers);

			//read the claim pokers
			msg = readmsg();
			strcpy(buf, msg.mtext);	
			printf("LOG: %d-----%s\n", msg.mtype, msg.mtext);
			sscanf(buf, "%*s%s", current_user_claim_pokers); 		
			printf("LOG: %d CURRENT_USER_CLAIM_POKERS: %s\n", connecter_fd[i], current_user_claim_pokers);
			broadcast(connecter_fd[i], current_user_claim_pokers);

			//Judge Part
			judgement(i, current_round_pokers, current_user_put_pokers, current_user_claim_pokers);

			//Add pokers part, under consideration, add this function further.
			

			printf("%s\n", msg.mtext);
			if (!strcmp(msg.mtext, "OVER"))
			{
				printf("GAME OVER, THE WINNER IS %d\n", msg.mtype);
				break;
			}
		}
	}
}
Esempio n. 29
0
bool Scene::onUpdate()
{
    if (getFloatSteadyNowTime() > _endTime || _players.empty())
    {
        return false;
    }

    _move->update();
    _skill->update();
    _ai->update();



    SceneRefreshNotice notice;
    EntityScriptNotice scripts;
    for (auto &kv : _entitys)
    {
        if (kv.second->_isStateDirty)
        {
            notice.entityStates.push_back(kv.second->_state);
            kv.second->_isStateDirty = false;
        }
        if (kv.second->_isMoveDirty)
        {
            notice.entityMoves.push_back(kv.second->_move);
            kv.second->_isMoveDirty = false;
        }
        scripts.controls.push_back(kv.second->_control);
        scripts.skills.push_back(kv.second->_skillSys);
    }
    if (!notice.entityStates.empty() || !notice.entityMoves.empty())
    {
        broadcast(notice);
    }
    
    _script->protoSync(scripts);
    //after flush data
    _script->update();

    while (!_asyncs.empty())
    {
        auto func = _asyncs.front();
        _asyncs.pop();
        func();
    }

    return true;
}
Esempio n. 30
0
bool Room::remove(Member *meb) {
    auto r_id = for_member_id(meb);
    if(error()) {
        m_err = "no this member";
        return false;
    }
    m_members[r_id] = nullptr;

    // 告诉其他成员自己退出房间
    mini_net_pkg pkg;
    pkg.msg = MESSAGE::quit_room;
    broadcast((net_pkg *)&pkg, r_id);

    g_dialog->output("[LOG] ROOM %s: %s quited.", m_name, meb->m_name);
    return true;
}