本文整理汇总了C++中Transport类的典型用法代码示例。如果您正苦于以下问题:C++ Transport类的具体用法?C++ Transport怎么用?C++ Transport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pthread_mutex_lock
int DataChn::connect(const string& ip, int port)
{
// no need to connect to self
if ((ip == m_strIP) && (port == m_iPort))
return 1;
Address addr;
addr.m_strIP = ip;
addr.m_iPort = port;
pthread_mutex_lock(&m_ChnLock);
map<Address, ChnInfo*, AddrComp>::iterator i = m_mChannel.find(addr);
if (i != m_mChannel.end())
{
if ((NULL != i->second->m_pTrans) && i->second->m_pTrans->isConnected())
{
pthread_mutex_unlock(&m_ChnLock);
return 0;
}
delete i->second->m_pTrans;
i->second->m_pTrans = NULL;
}
ChnInfo* c = NULL;
if (i == m_mChannel.end())
{
c = new ChnInfo;
c->m_pTrans = NULL;
pthread_mutex_init(&c->m_SndLock, NULL);
pthread_mutex_init(&c->m_RcvLock, NULL);
pthread_mutex_init(&c->m_QueueLock, NULL);
m_mChannel[addr] = c;
}
else
{
c = i->second;
}
pthread_mutex_unlock(&m_ChnLock);
pthread_mutex_lock(&c->m_SndLock);
if ((NULL != c->m_pTrans) && c->m_pTrans->isConnected())
{
c->m_iCount ++;
pthread_mutex_unlock(&c->m_SndLock);
return 0;
}
Transport* t = new Transport;
t->open(m_iPort, true, true);
int r = t->connect(ip.c_str(), port);
if (NULL == c->m_pTrans)
c->m_pTrans = t;
else
{
Transport* tmp = c->m_pTrans;
c->m_pTrans = t;
delete tmp;
}
pthread_mutex_unlock(&c->m_SndLock);
return r;
}
开发者ID:besquared,项目名称:sector-sphere,代码行数:65,代码来源:datachn.cpp
示例2: testMemLeak
/**
* test Server and Client memory leak
* test whether packets are deleted when connection closed
*/
void TCPCONNECTIONTF::testMemLeak() {
char spec[] = "tcp:localhost:13147";
int64_t now = TimeUtil::getTime();
Transport *tranServer = new Transport;
Transport *tranClient = new Transport;
ConnServerAdapter *adapter = new ConnServerAdapter;
//add listener to tranServer
IOComponent *listener = tranServer->listen(spec, _streamer, adapter);
CPPUNIT_ASSERT(listener);
tranServer->eventIteration(now);
//create a connection
Connection *conn = tranClient->connect(spec, _streamer, false);
CPPUNIT_ASSERT(conn);
tranClient->eventIteration(now);
//accept the connection
tranServer->eventIteration(now);
// client send two packets
_conn->postPacket(new ConnPacket, _handler, NULL, true);
_conn->postPacket(new ConnPacket, _handler, NULL, true);
tranClient->eventIteration(now);
//server accept two packets
tranServer->eventIteration(now);
IOComponent *ioc = tranServer->_iocListTail;
Connection *tmpConn = ((TCPComponent *)ioc)->_connection;
//client close the connection
_conn->close();
tranClient->eventIteration(now);
tranServer->eventIteration(now);
CPPUNIT_ASSERT_EQUAL((size_t)0, tmpConn->_outputQueue.size());
delete adapter;
delete tranClient;
delete tranServer;
listener->subRef();
conn->subRef();
}
开发者ID:AllanXiang,项目名称:Source,代码行数:48,代码来源:tcpconnectiontf.cpp
示例3: getFilter
bool HostFilterComponent::perform (const InvocationInfo& info)
{
Config* config = Config::getInstance();
GraphComponent* graph = main->getGraph ();
Transport* transport = getFilter()->getTransport();
switch (info.commandID)
{
//----------------------------------------------------------------------------------------------
case CommandIDs::pluginOpen:
{
graph->loadAndAppendPlugin ();
break;
}
case CommandIDs::pluginClose:
{
graph->closeSelectedPlugins ();
break;
}
case CommandIDs::pluginClear:
{
graph->closeAllPlugins ();
break;
}
case CommandIDs::showPluginListEditor:
{
if (PluginListWindow::currentPluginListWindow == 0)
PluginListWindow::currentPluginListWindow = new PluginListWindow (knownPluginList);
PluginListWindow::currentPluginListWindow->toFront (true);
break;
}
//----------------------------------------------------------------------------------------------
#ifndef JOST_VST_PLUGIN
case CommandIDs::audioOptions:
{
StandaloneFilterWindow* window = findParentComponentOfClass ((StandaloneFilterWindow*) 0);
if (window)
window->showAudioSettingsDialog ();
break;
}
#endif
case CommandIDs::audioPlay:
{
transport->play ();
break;
}
case CommandIDs::audioPlayPause:
{
transport->togglePlay ();
break;
}
case CommandIDs::audioStop:
{
transport->stop ();
break;
}
case CommandIDs::audioRecord:
{
transport->record ();
break;
}
case CommandIDs::audioRewind:
{
transport->rewind ();
break;
}
case CommandIDs::audioLoop:
{
transport->setLooping (! transport->isLooping());
break;
}
//----------------------------------------------------------------------------------------------
case CommandIDs::sessionNew:
{
bool retValue =
AlertWindow::showYesNoCancelBox (AlertWindow::WarningIcon,
T("Unsaved Changes"),
T("Are you sure you want to close the current session? You may lose any unsaved changes."));
if (retValue)
{
closePluginEditorWindows ();
getFilter()->getHost ()->closeAllPlugins (true);
clearComponents ();
Config::getInstance()->lastSessionFile = File::nonexistent;
rebuildComponents ();
}
break;
}
case CommandIDs::sessionLoad:
{
FileChooser myChooser (T("Load a session file..."),
//.........这里部分代码省略.........
开发者ID:christianscheuer,项目名称:jivemodular,代码行数:101,代码来源:HostFilterComponent.cpp
示例4: f_header
void f_header(CStrRef str, bool replace /* = true */,
int http_response_code /* = 0 */) {
if (f_headers_sent()) {
raise_warning("Cannot modify header information - headers already sent");
}
String header = f_rtrim(str);
// new line safety check
// NOTE: PHP actually allows "\n " and "\n\t" to fall through. Is that bad
// for security?
if (header.find('\n') >= 0 || header.find('\r') >= 0) {
raise_warning("Header may not contain more than a single header, "
"new line detected");
return;
}
Transport *transport = g_context->getTransport();
if (transport && header->size()) {
const char *header_line = header->data();
// handle single line of status code
if (header->size() >= 5 && strncasecmp(header_line, "HTTP/", 5) == 0) {
int code = 200;
for (const char *ptr = header_line; *ptr; ptr++) {
if (*ptr == ' ' && *(ptr + 1) != ' ') {
code = atoi(ptr + 1);
break;
}
}
if (code) {
transport->setResponse(code, "explicit_header");
}
return;
}
const char *colon_offset = strchr(header_line, ':');
String newHeader;
if (colon_offset) {
if (!strncasecmp(header_line, "Content-Type",
colon_offset - header_line)) {
const char *ptr = colon_offset+1, *mimetype = NULL;
while (*ptr == ' ') ptr++;
mimetype = ptr;
if (strncmp(mimetype, "text/", 5) == 0 &&
strstr(mimetype, "charset=") == NULL) {
newHeader = header + ";charset=utf-8";
}
}
}
if (replace) {
transport->replaceHeader(newHeader.empty() ? header : newHeader);
} else {
transport->addHeader(newHeader.empty() ? header : newHeader);
}
if (http_response_code) {
transport->setResponse(http_response_code,
"explicit_header_response_code");
}
}
}
开发者ID:MarcReis,项目名称:hiphop-php,代码行数:61,代码来源:ext_network.cpp
示例5: getMSTime
void MapManager::LoadTransports()
{
uint32 oldMSTime = getMSTime();
QueryResult result = WorldDatabase.Query("SELECT guid, entry, name, period, ScriptName FROM transports");
if (!result)
{
sLog->outString(">> Loaded 0 transports. DB table `transports` is empty!");
sLog->outString();
return;
}
uint32 count = 0;
do
{
Field *fields = result->Fetch();
uint32 lowguid = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
std::string name = fields[2].GetString();
uint32 period = fields[3].GetUInt32();
uint32 scriptId = sObjectMgr->GetScriptId(fields[4].GetCString());
Transport *t = new Transport(period, scriptId);
const GameObjectInfo *goinfo = ObjectMgr::GetGameObjectInfo(entry);
if (!goinfo)
{
sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
delete t;
continue;
}
if (goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
{
sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template type wrong", entry, name.c_str());
delete t;
continue;
}
// sLog->outString("Loading transport %d between %s, %s", entry, name.c_str(), goinfo->name);
std::set<uint32> mapsUsed;
if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
// skip transports with empty waypoints list
{
sLog->outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.", goinfo->moTransport.taxiPathId);
delete t;
continue;
}
float x = t->m_WayPoints[0].x;
float y = t->m_WayPoints[0].y;
float z = t->m_WayPoints[0].z;
uint32 mapid = t->m_WayPoints[0].mapid;
float o = 1.0f;
// creates the Gameobject
if (!t->Create(lowguid, entry, mapid, x, y, z, o, 100, 0))
{
delete t;
continue;
}
m_Transports.insert(t);
for (std::set<uint32>::const_iterator i = mapsUsed.begin(); i != mapsUsed.end(); ++i)
m_TransportsByMap[*i].insert(t);
//If we someday decide to use the grid to track transports, here:
t->SetMap(sMapMgr->CreateMap(mapid, t, 0));
t->AddToWorld();
++count;
}
while (result->NextRow());
// check transport data DB integrity
result = WorldDatabase.Query("SELECT gameobject.guid, gameobject.id, transports.name FROM gameobject, transports WHERE gameobject.id = transports.entry");
if (result) // wrong data found
{
do
{
Field *fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
std::string name = fields[2].GetString();
sLog->outErrorDb("Transport %u '%s' have record (GUID: %u) in `gameobject`. Transports DON'T must have any records in `gameobject` or its behavior will be unpredictable/bugged.", entry, name.c_str(), guid);
}
while (result->NextRow());
}
sLog->outString(">> Loaded %u transports in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
开发者ID:XEQT,项目名称:SkyFireEMU,代码行数:99,代码来源:Transport.cpp
示例6: uri
int CmdPull::execute (std::string& output)
{
context.footnote ("The 'pull' command is deprecated, and will be removed in a subsequent release.");
std::vector <std::string> words = context.a3.extract_words ();
std::string file;
if (words.size ())
file = words[0];
Uri uri (file, "pull");
uri.parse ();
if (uri._data.length ())
{
Directory location (context.config.get ("data.location"));
if (! uri.append ("{pending,undo,completed}.data"))
throw format (STRING_CMD_PULL_NOT_DIR, uri._path);
Transport* transport;
if ((transport = Transport::getTransport (uri)) != NULL)
{
transport->recv (location._data + "/");
delete transport;
}
else
{
// Verify that files are not being copied from rc.data.location to the
// same place.
if (Directory (uri._path) == Directory (context.config.get ("data.location")))
throw std::string (STRING_CMD_PULL_SAME);
// copy files locally
// remove {pending,undo,completed}.data
uri._path = uri.parent();
Path path1 (uri._path + "undo.data");
Path path2 (uri._path + "pending.data");
Path path3 (uri._path + "completed.data");
if (path1.exists() && path2.exists() && path3.exists())
{
// if (confirm ("xxxxxxxxxxxxx"))
// {
std::ofstream ofile1 ((location._data + "/undo.data").c_str(), std::ios_base::binary);
std::ifstream ifile1 (path1._data.c_str() , std::ios_base::binary);
ofile1 << ifile1.rdbuf();
std::ofstream ofile2 ((location._data + "/pending.data").c_str(), std::ios_base::binary);
std::ifstream ifile2 (path2._data.c_str() , std::ios_base::binary);
ofile2 << ifile2.rdbuf();
std::ofstream ofile3 ((location._data + "/completed.data").c_str(), std::ios_base::binary);
std::ifstream ifile3 (path3._data.c_str() , std::ios_base::binary);
ofile3 << ifile3.rdbuf();
// }
}
else
{
throw format (STRING_CMD_PULL_MISSING, uri._path);
}
}
output += format (STRING_CMD_PULL_TRANSFERRED, uri.ToString ()) + "\n";
}
else
throw std::string (STRING_CMD_PULL_NO_URI);
return 0;
}
开发者ID:georgebrock,项目名称:task,代码行数:71,代码来源:CmdPull.cpp
示例7: sync
void sync(Transport tr){
//std::cout << tr.toString() << std::endl;
transport_string = tr.toString() ;
if(playing){
Transport diff = tr - last_transport;
t = diff.toSec();
ros::Duration elapsed = ros::Time::now() - last_update_time;
sync_offset = t - elapsed.toSec();
offset_string = std::to_string(sync_offset);
//upon reaching a new bar, obtain note info for the next bar
if(tr.position.bar != last_transport.position.bar || tr.tempo != last_transport.tempo){
double cur_t = (ros::Time::now() - playback_start_time).toSec();
//information about the beats
std::vector<terpsichore::pair> beats;
//binary bars
//if(tr.timeSignature.beatsPerBar % 2 == 0){
for(int i = 1; i <= tr.timeSignature.beatsPerBar; i++){
double beats_ahead = (1 * tr.timeSignature.beatsPerBar) + (i - 1);
double beat_time = ((double)(beats_ahead + (tr.position.unit/tr.position.resolution))/tr.tempo) * 60.0 + cur_t;
terpsichore::pair b;
std::vector<double> d;
b.t = beat_time;
if(i % 2 == 0){
//weak beat
d.push_back(0.5);
}else{
//stronk beat
d.push_back(1.0);
}
b.data = d;
beats.push_back(b);
}
//}
bardata.beats = beats;
std::vector<terpsichore::pair> events;
//grab the first clip in the map
std::map<int, Clip*>::iterator it = listener->clips.begin();
if(it != listener->clips.end()){
Clip* c = it->second;
//std::cout << "now in " << tr.position.toString() << std::endl;
for(std::multimap<Position, Note>::iterator it = c->notes.begin(); it != c->notes.end(); it++){
Position p = it->first;
if(p.bar == (tr.position.bar + 1) || (tr.position.bar) % c->length.bar + 1 == p.bar){
Note n = it->second;
terpsichore::pair d;
d.t = (1.0 * tr.timeSignature.beatsPerBar + p.toFloat(tr.timeSignature))/tr.tempo * 60.0 + cur_t;
double scaled_pitch = (double)(n.pitch)/(double)(108);
double scaled_vel = double(n.velocity)/(double)(127);
std::vector<double> info;
info.push_back(scaled_pitch);
info.push_back((double)n.duration);
info.push_back(scaled_vel);
d.data = info;
events.push_back(d);
//std::cout << "added note in " << p.toString() << std::endl;
}else{
//std::cout << "not adding the note in " << p.toString() << std::endl;
continue;
}
}
bardata.events = events;
}
data_pub.publish(bardata);
}
}
last_update_time = ros::Time::now();
last_transport = tr;
}
开发者ID:natashad,项目名称:Max_Ros,代码行数:77,代码来源:ConductorNode.cpp
示例8: SetMap
bool AreaTrigger::Create(uint32 spellMiscId, Unit* caster, Unit* target, SpellInfo const* spell, Position const& pos, int32 duration, uint32 spellXSpellVisualId, ObjectGuid const& castId, AuraEffect const* aurEff)
{
_targetGuid = target ? target->GetGUID() : ObjectGuid::Empty;
_aurEff = aurEff;
SetMap(caster->GetMap());
Relocate(pos);
if (!IsPositionValid())
{
TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (spellMiscId %u) not created. Invalid coordinates (X: %f Y: %f)", spellMiscId, GetPositionX(), GetPositionY());
return false;
}
_areaTriggerMiscTemplate = sAreaTriggerDataStore->GetAreaTriggerMiscTemplate(spellMiscId);
if (!_areaTriggerMiscTemplate)
{
TC_LOG_ERROR("entities.areatrigger", "AreaTrigger (spellMiscId %u) not created. Invalid areatrigger miscid (%u)", spellMiscId, spellMiscId);
return false;
}
Object::_Create(ObjectGuid::Create<HighGuid::AreaTrigger>(GetMapId(), GetTemplate()->Id, caster->GetMap()->GenerateLowGuid<HighGuid::AreaTrigger>()));
SetEntry(GetTemplate()->Id);
SetDuration(duration);
SetObjectScale(1.0f);
SetGuidValue(AREATRIGGER_CASTER, caster->GetGUID());
SetGuidValue(AREATRIGGER_CREATING_EFFECT_GUID, castId);
SetUInt32Value(AREATRIGGER_SPELLID, spell->Id);
SetUInt32Value(AREATRIGGER_SPELL_FOR_VISUALS, spell->Id);
SetUInt32Value(AREATRIGGER_SPELL_X_SPELL_VISUAL_ID, spellXSpellVisualId);
SetUInt32Value(AREATRIGGER_TIME_TO_TARGET_SCALE, GetMiscTemplate()->TimeToTargetScale != 0 ? GetMiscTemplate()->TimeToTargetScale : GetUInt32Value(AREATRIGGER_DURATION));
SetFloatValue(AREATRIGGER_BOUNDS_RADIUS_2D, GetTemplate()->MaxSearchRadius);
SetUInt32Value(AREATRIGGER_DECAL_PROPERTIES_ID, GetMiscTemplate()->DecalPropertiesId);
for (uint8 scaleCurveIndex = 0; scaleCurveIndex < MAX_AREATRIGGER_SCALE; ++scaleCurveIndex)
if (GetMiscTemplate()->ScaleInfo.ExtraScale[scaleCurveIndex].AsInt32)
SetUInt32Value(AREATRIGGER_EXTRA_SCALE_CURVE + scaleCurveIndex, GetMiscTemplate()->ScaleInfo.ExtraScale[scaleCurveIndex].AsInt32);
PhasingHandler::InheritPhaseShift(this, caster);
if (target && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))
{
m_movementInfo.transport.guid = target->GetGUID();
}
UpdateShape();
uint32 timeToTarget = GetMiscTemplate()->TimeToTarget != 0 ? GetMiscTemplate()->TimeToTarget : GetUInt32Value(AREATRIGGER_DURATION);
if (GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_CIRCULAR_MOVEMENT))
{
AreaTriggerCircularMovementInfo cmi = GetMiscTemplate()->CircularMovementInfo;
if (target && GetTemplate()->HasFlag(AREATRIGGER_FLAG_HAS_ATTACHED))
cmi.PathTarget = target->GetGUID();
else
cmi.Center = pos;
InitCircularMovement(cmi, timeToTarget);
}
else if (GetMiscTemplate()->HasSplines())
{
InitSplineOffsets(GetMiscTemplate()->SplinePoints, timeToTarget);
}
// movement on transport of areatriggers on unit is handled by themself
Transport* transport = m_movementInfo.transport.guid.IsEmpty() ? caster->GetTransport() : nullptr;
if (transport)
{
float x, y, z, o;
pos.GetPosition(x, y, z, o);
transport->CalculatePassengerOffset(x, y, z, &o);
m_movementInfo.transport.pos.Relocate(x, y, z, o);
// This object must be added to transport before adding to map for the client to properly display it
transport->AddPassenger(this);
}
AI_Initialize();
// Relocate areatriggers with circular movement again
if (HasCircularMovement())
Relocate(CalculateCircularMovementPosition());
if (!GetMap()->AddToMap(this))
{
// Returning false will cause the object to be deleted - remove from transport
if (transport)
transport->RemovePassenger(this);
return false;
}
caster->_RegisterAreaTrigger(this);
_ai->OnCreate();
return true;
}
开发者ID:welder1976,项目名称:TrinityCore,代码行数:100,代码来源:AreaTrigger.cpp
示例9: main
//.........这里部分代码省略.........
vector_fp X2set(nsp, 0.0);
X2set[0] = 0.25 ;
X2set[5] = 0.17;
X2set[14] = 0.15;
X2set[15] = 0.05;
X2set[47] = 0.38 ;
double T2 = 1200.;
double dist = 0.1;
vector_fp X3set(nsp, 0.0);
X3set[0] = 0.27 ;
X3set[5] = 0.15;
X3set[14] = 0.18;
X3set[15] = 0.06;
X3set[47] = 0.36 ;
double T3 = 1400.;
vector_fp grad_T(3, 0.0);
Array2D grad_X(nsp, 2, 0.0);
for( k = 0; k < nsp; k++) {
grad_X(k,0) = (X2set[k] - Xset[k])/dist;
grad_X(k,1) = (X3set[k] - Xset[k])/dist;
}
grad_T[0] = (T2 - T1) / dist;
grad_T[1] = (T3 - T1) / dist;
int log_level = 0;
Transport * tran = newTransportMgr("Multi", &g, log_level=0);
MultiTransport * tranMix = dynamic_cast<MultiTransport *>(tran);
g.setState_TPX(1500.0, pres, DATA_PTR(Xset));
vector_fp mixDiffs(nsp, 0.0);
tranMix->getMixDiffCoeffs(DATA_PTR(mixDiffs));
printf(" Dump of the mixture Diffusivities:\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), mixDiffs[k]);
}
vector_fp specVisc(nsp, 0.0);
tranMix->getSpeciesViscosities(DATA_PTR(specVisc));
printf(" Dump of the species viscosities:\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
printf(" %15s %13.5g\n", sss.c_str(), specVisc[k]);
}
vector_fp thermDiff(nsp, 0.0);
tranMix->getThermalDiffCoeffs(DATA_PTR(thermDiff));
printf(" Dump of the Thermal Diffusivities :\n");
for (k = 0; k < nsp; k++) {
string sss = g.speciesName(k);
double ddd = cutoff(thermDiff[k]);
开发者ID:hkmoffat,项目名称:cantera,代码行数:67,代码来源:multiGasTransport.cpp
示例10: CHECK_PACKET_SIZE
//.........这里部分代码省略.........
lt->tm_hour << 6 | lt->tm_min;
data << xmitTime;
data << (float)0.017f; // game speed
SendPacket( &data );
GetPlayer()->UpdateHonorFields();
QueryResult *result = sDatabase.PQuery("SELECT `guildid`,`rank` FROM `guild_member` WHERE `guid` = '%u'",pCurrChar->GetGUIDLow());
if(result)
{
Field *fields = result->Fetch();
pCurrChar->SetInGuild(fields[0].GetUInt32());
pCurrChar->SetRank(fields[1].GetUInt32());
delete result;
}
else if(pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
{
pCurrChar->SetInGuild(0);
pCurrChar->SetRank(0);
}
if (!MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->AddInstanced(pCurrChar))
{
// TODO : Teleport to zone-in area
}
MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->Add(pCurrChar);
ObjectAccessor::Instance().InsertPlayer(pCurrChar);
//sLog.outDebug("Player %s added to Map.",pCurrChar->GetName());
if (pCurrChar->m_transport)
{
Transport* curTrans = pCurrChar->m_transport;
pCurrChar->TeleportTo(curTrans->GetMapId(), curTrans->GetPositionX(), curTrans->GetPositionY(), curTrans->GetPositionZ(), curTrans->GetOrientation(), true, false);
}
sDatabase.PExecute("UPDATE `character` SET `online` = 1 WHERE `guid` = '%u'", pCurrChar->GetGUIDLow());
loginDatabase.PExecute("UPDATE `account` SET `online` = 1 WHERE `id` = '%u'", GetAccountId());
plr->SetInGameTime( getMSTime() );
// set some aura effects after add player to map
if(pCurrChar->HasAuraType(SPELL_AURA_MOD_STUN))
pCurrChar->SetMovement(MOVE_ROOT);
if(pCurrChar->HasAuraType(SPELL_AURA_MOD_ROOT))
{
WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10);
data.append(pCurrChar->GetPackGUID());
data << (uint32)2;
pCurrChar->SendMessageToSet(&data,true);
}
// announce group about member online (must be after add to player list to receive announce to self)
if(pCurrChar->groupInfo.group)
{
//pCurrChar->groupInfo.group->SendInit(this); // useless
pCurrChar->groupInfo.group->SendUpdate();
}
// friend status
data.Initialize(SMSG_FRIEND_STATUS, 19);
data<<uint8(FRIEND_ONLINE);
data<<pCurrChar->GetGUID();
data<<uint8(1);
data<<pCurrChar->GetAreaId();
开发者ID:Artea,项目名称:mangos-svn,代码行数:67,代码来源:CharacterHandler.cpp
示例11: main
int main(int argc, char *argv[]) {
if(2 > argc) {
printf("Less address!\n");
return 1;
}
Logger::logSetup();
Logger::setLogLevel(0);
char *address = argv[1];
char host[100] = {0};
char path[1024*1024] = {0};
char spec[200] = {0};
int port = -1;
sscanf(address, "http://%[-a-zA-Z0-9.]:%d%s", host, &port, path);
if(0 == host[0] || -1 == port) {
sscanf(address, "%[-a-zA-Z0-9.]:%d%s", host, &port, path);
}
if(0 == host[0] || -1 == port) {
port = 80;
sscanf(address, "http://%[-a-zA-Z0-9.]%s", host, path);
}
if(0 == host[0] || -1 == port) {
sscanf(address, "%[-a-zA-Z0-9.]%s", host, path);
}
if(0 == host[0] || -1 == port) {
printf("Wrong address!\n");
return 1;
}
if(0 == path[0]) {
path[0] = '/';
path[1] = 0;
}
sprintf(spec, "tcp:%s:%d", host, port);
Transport transport;
transport.start();
Connection *connection = NULL;
HTTPPacketFactory factory;
HTTPStreamer streamer(&factory);
connection = transport.connect(spec, &streamer);
if (NULL == connection) {
printf("Failed to connect server %s\n", spec);
exit(1);
}
HTTPPacket *requst = new HTTPPacket;
requst->setMethod(HTTPPacket::HM_GET);
requst->setURI(path);
requst->addHeader("Accept", "*/*");
requst->addHeader("Connection", "Keep-Alive");
requst->addHeader("Host", (const char*)(spec+4));
Packet *ret = connection->sendPacket(requst);
HTTPPacket *reply = NULL;
if (NULL != ret && ret->isRegularPacket()
&& (reply = dynamic_cast<HTTPPacket*>(ret)))
{
printf("------------reply from '%s' ----------\r\n", address);
printf("%s %d %s\r\n", reply->getVersion() ? "HTTP/1.1" : "HTTP/1.0",
reply->getStatusCode(), reply->getReasonPhrase());
for (HTTPPacket::ConstHeaderIterator it = reply->headerBegin();
it != reply->headerEnd(); it ++)
{
printf("%s: %s\r\n", it->first, it->second);
}
printf("\r\n");
if (reply->getBody()) {
fwrite(reply->getBody(), 1, reply->getBodyLen(), stdout);
}
printf("\n-----------end of reply-------------------\n");
} else {
printf("Fail to get reply from '%s' ----------\r\n", address);
ControlPacket *cmd = dynamic_cast<ControlPacket*>(ret);
if (cmd) {
printf("%s", cmd->what());
}
}
connection->subRef();
transport.stop();
transport.wait();
return 0;
}
开发者ID:AllanXiang,项目名称:Source,代码行数:80,代码来源:helloworld_wget_syn.cpp
示例12: showVehichle
void showVehichle( Transport& transport ) {
transport.showWheels();
}
开发者ID:mnishiguchi,项目名称:cpp_notebook,代码行数:3,代码来源:main.cpp
示例13: HandleGoCreatureCommand
//teleport to creature
static bool HandleGoCreatureCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* player = handler->GetSession()->GetPlayer();
// "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
char* param1 = handler->extractKeyFromLink((char*)args, "Hcreature");
if (!param1)
return false;
std::ostringstream whereClause;
// User wants to teleport to the NPC's template entry
if (strcmp(param1, "id") == 0)
{
// Get the "creature_template.entry"
// number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
char* tail = strtok(NULL, "");
if (!tail)
return false;
char* id = handler->extractKeyFromLink(tail, "Hcreature_entry");
if (!id)
return false;
int32 entry = atoi(id);
if (!entry)
return false;
whereClause << "WHERE id = '" << entry << '\'';
}
else
{
int32 guid = atoi(param1);
// Number is invalid - maybe the user specified the mob's name
if (!guid)
{
std::string name = param1;
WorldDatabase.EscapeString(name);
whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name " _LIKE_" '" << name << '\'';
}
else
whereClause << "WHERE guid = '" << guid << '\'';
}
QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, guid, id FROM creature %s", whereClause.str().c_str());
if (!result)
{
handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);
handler->SetSentErrorMessage(true);
return false;
}
if (result->GetRowCount() > 1)
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
Field* fields = result->Fetch();
float x = fields[0].GetFloat();
float y = fields[1].GetFloat();
float z = fields[2].GetFloat();
float o = fields[3].GetFloat();
uint32 mapId = fields[4].GetUInt16();
Transport* transport = NULL;
if (!MapManager::IsValidMapCoord(mapId, x, y, z, o) || sObjectMgr->IsTransportMap(mapId))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true);
return false;
}
// stop flight if need
if (player->IsInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
if (player->TeleportTo(mapId, x, y, z, o))
{
if (transport)
transport->AddPassenger(player);
}
return true;
}
开发者ID:deathkayn,项目名称:Core-W,代码行数:91,代码来源:cs_go.cpp
示例14: create_vm_event_request
void VMEvent::create_event_request(PacketInputStream *in,
PacketOutputStream *out, jbyte event_kind)
{
UsingFastOops fast_oops;
VMEvent::Fast ep;
int i;
bool error = false;
VMEventModifier::Fast current_modifier_slot, new_modifier, event_modifier;
ep = create_vm_event_request();
ep().set_event_kind(event_kind);
ep().set_suspend_policy(in->read_byte());
ep().set_num_modifiers(in->read_int());
Transport *transport = in->transport();
ep().set_transport(transport);
#if ENABLE_ISOLATES
ep().set_task_id(transport->task_id());
TaskGCContext tmp(transport->task_id());
#endif
for (i=0; i < ep().num_modifiers(); i++) {
new_modifier = VMEventModifier::new_modifier(in, out, error);
if (error) {
// some sort of error happened
if (out->error() != 0) {
out->send_packet();
}
return;
}
if (new_modifier.is_null()) {
// Most likely we don't support this modifier
continue;
}
if (event_kind == JDWP_EventKind_BREAKPOINT &&
new_modifier().mod_kind() ==
JDWP_EventRequest_Set_Out_modifiers_Modifier_LocationOnly) {
UsingFastOops fastoops2;
LocationModifier *lmp = (LocationModifier *)&new_modifier;
VMEvent::Fast epb = VMEvent::find_breakpoint_event(lmp,
transport->task_id());
if (epb.not_null()) {
out->write_int(epb().event_id());
out->send_packet();
// out->send_error(JDWP_Error_NOT_IMPLEMENTED);
// there's a breakpoint here already, don't bother installing another
return;
}
#if ENABLE_ISOLATES
InstanceClass::Raw ic = JavaDebugger::get_object_by_id(new_modifier().clazz_id());
if (ic().class_id() < ROM::number_of_system_classes()) {
// breakpoint in system class, allow in any task
ep().set_task_id(-1);
}
// See if any other task already has a breakpoint here.
epb = find_breakpoint_event(lmp);
if (!epb.is_null()) {
// Has to be some other task since we haven't linked in this event
GUARANTEE(epb().task_id() != transport->task_id(),
"Breakpoint already inserted");
LocationModifier::Raw lmod = get_modifier(&epb,
JDWP_EventRequest_Set_Out_modifiers_Modifier_LocationOnly);
GUARANTEE(!lmod.is_null(),"Breakpoint event has no location modifier");
lmp->set_save_opcode(lmod().save_opcode());
} else {
#endif
/* Return an error back to the debugger if
* the breakpoint could not be installed.
*/
lmp->unlink_method();
lmp->save_method_entry();
if (lmp->set_method_opcode(Bytecodes::_breakpoint, true) ==
false){
out->send_error(JDWP_Error_INVALID_LOCATION);
return;
}
#if ENABLE_ISOLATES
}
#endif
}
// insert the mod at the end of the list of modifiers
event_modifier = ep().mods();
if (event_modifier.is_null()) {
ep().set_mods(&new_modifier);
current_modifier_slot = ep().mods();
} else {
current_modifier_slot().set_next(&new_modifier);
current_modifier_slot = new_modifier;
}
}
#ifdef AZZERT
if (TraceDebugger) {
tty->print_cr("Create Event: xprt = 0x%x, ep = 0x%lx, id = 0x%x, kind = 0x%lx, suspend = 0x%lx, num mods = 0x%lx",
transport->obj(),
ep.obj(),
ep().event_id(),
ep().event_kind(),
ep().suspend_policy(),
//.........这里部分代码省略.........
开发者ID:jiangxilong,项目名称:yari,代码行数:101,代码来源:VMEvent.cpp
示例15: transport_example2
int transport_example2(int job) {
try {
cout << "Multicomponent transport properties." << endl;
if (job > 0) {
cout << "Viscosity, thermal conductivity, and thermal diffusion\n"
" coefficients at 2 atm for a "
<< "range of temperatures" << endl;
}
if (job <= 1) return 0;
// header
writeCanteraHeader(cout);
// create a gas mixture, and set its state
IdealGasMix gas("gri30.cti", "gri30");
doublereal temp = 2000.0;
doublereal pres = 2.0*OneAtm;
gas.setState_TPX(temp, pres, "H2:1.0, O2:0.5, CH4:0.1, N2:0.2");
equilibrate(gas,"TP");
// create a transport manager that implements
// multicomponent transport properties
Transport* tr = newTransportMgr("Multi", &gas);
int nsp = gas.nSpecies();
// create a 2D array to hold the outputs
int ntemps = 20;
Array2D output(nsp+3, ntemps);
// main loop
clock_t t0 = clock();
for (int i = 0; i < ntemps; i++) {
temp = 500.0 + 100.0*i;
gas.setState_TP(temp, pres);
output(0,i) = temp;
output(1,i) = tr->viscosity();
output(2,i) = tr->thermalConductivity();
tr->getThermalDiffCoeffs(&output(3,i));
}
clock_t t1 = clock();
// make a Tecplot data file and an Excel spreadsheet
string plotTitle = "transport example 2: "
"multicomponent transport properties";
plotTransportSoln("tr2.dat", "TEC", plotTitle, gas, output);
plotTransportSoln("tr2.csv", "XL", plotTitle, gas, output);
// print final temperature and timing data
doublereal tmm = 1.0*(t1 - t0)/CLOCKS_PER_SEC;
cout << " time = " << tmm << endl << endl;
cout << "Output files:" << endl
<< " tr2.csv (Excel CSV file)" << endl
<< " tr2.dat (Tecplot data file)" << endl;
return 0;
}
// handle exceptions thrown by Cantera
catch (CanteraError) {
showErrors(cout);
cout << " terminating... " << endl;
appdelete();
return -1;
}
}
开发者ID:anujg1991,项目名称:cantera,代码行数:73,代码来源:transport_example2.cpp
示例16: real_position
int32 MoveSplineInit::Launch()
{
float realSpeedRun = 0.0f;
MoveSpline& move_spline = *unit.movespline;
Transport* newTransport = NULL;
if (args.transportGuid)
newTransport = HashMapHolder<Transport>::Find(ObjectGuid(HIGHGUID_MO_TRANSPORT, args.transportGuid));
Vector3 real_position(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZ());
// there is a big chance that current position is unknown if current state is not finalized, need compute it
// this also allows calculate spline position and update map position in much greater intervals
if (!move_spline.Finalized())
{
real_position = move_spline.ComputePosition();
Transport* oldTransport = NULL;
if (move_spline.GetTransportGuid())
oldTransport = HashMapHolder<Transport>::Find(ObjectGuid(HIGHGUID_MO_TRANSPORT, move_spline.GetTransportGuid()));
if (oldTransport)
oldTransport->CalculatePassengerPosition(real_position.x, real_position.y, real_position.z);
}
if (newTransport)
newTransport->CalculatePassengerOffset(real_position.x, real_position.y, real_position.z);
if (args.path.empty())
{
// should i do the things that user should do?
MoveTo(real_position);
}
// corrent first vertex
args.path[0] = real_position;
uint32 moveFlags = unit.m_movementInfo.GetMovementFlags();
uint32 oldMoveFlags = moveFlags;
if (args.flags.done)
{
args.flags = MoveSplineFlag::Done;
moveFlags &= ~(MOVEFLAG_SPLINE_ENABLED | MOVEFLAG_MASK_MOVING);
}
else
{
moveFlags |= (MOVEFLAG_SPLINE_ENABLED | MOVEFLAG_FORWARD);
if (args.flags.runmode)
moveFlags &= ~MOVEFLAG_WALK_MODE;
else
moveFlags |= MOVEFLAG_WALK_MODE;
}
if (newTransport)
moveFlags |= MOVEFLAG_ONTRANSPORT;
else
moveFlags &= ~MOVEFLAG_ONTRANSPORT;
if (args.velocity == 0.f)
realSpeedRun = args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags));
else
realSpeedRun = unit.GetSpeed(MOVE_RUN);
if (!args.Validate(&unit))
return 0;
unit.m_movementInfo.SetMovementFlags((MovementFlags)moveFlags);
unit.clearUnitState(UNIT_STAT_CLIENT_ROOT);
move_spline.SetMovementOrigin(movementType);
move_spline.Initialize(args);
WorldPacket data(SMSG_MONSTER_MOVE, 64);
data << unit.GetPackGUID();
if (newTransport)
{
data.SetOpcode(SMSG_MONSTER_MOVE_TRANSPORT);
data << newTransport->GetPackGUID();
}
if (unit.GetTransport() && unit.GetTransport() != newTransport)
unit.GetTransport()->RemovePassenger(&unit);
if (newTransport && unit.GetTransport() != newTransport)
newTransport->AddPassenger(&unit);
// Stop packet
if (args.flags.done)
{
data << real_position.x << real_position.y << real_position.z;
data << move_spline.GetId();
data << uint8(1); // MonsterMoveStop=1
}
else
move_spline.setLastPointSent(PacketBuilder::WriteMonsterMove(move_spline, data));
// Compress data or not ?
bool compress = false;
if (!args.flags.done && args.velocity > 4 * realSpeedRun)
compress = true;
else if ((data.wpos() + 2) > 0x10)
compress = true;
else if (unit.hasUnitState(UNIT_STAT_CLIENT_ROOT))
compress = true;
// Since packet size is stored with an uint8, packet size i
|
请发表评论