本文整理汇总了C++中ZoneServer::SendPacket方法的典型用法代码示例。如果您正苦于以下问题:C++ ZoneServer::SendPacket方法的具体用法?C++ ZoneServer::SendPacket怎么用?C++ ZoneServer::SendPacket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZoneServer
的用法示例。
在下文中一共展示了ZoneServer::SendPacket方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessServerOP_ZoneToZoneRequest
void ZoneServer::ProcessServerOP_ZoneToZoneRequest(ServerPacket* pack)
{
if (pack->size != sizeof(ZoneToZone_Struct))
{
cout << "Wrong size on ServerOP_ZoneToZoneRequest. Got: " << pack->size << ", Expected: " << sizeof(ZoneToZone_Struct) << endl;
return;
}
ZoneToZone_Struct* ztz = (ZoneToZone_Struct*) pack->pBuffer;
ZoneServer* zsc = 0;
if (GetZoneID() == ztz->current_zone_id)
{
zsc = this;
}
else
zsc = zoneserver_list.FindByZoneID(ztz->current_zone_id);
if(zsc == 0)
return;
if(GetZoneID() == ztz->current_zone_id)
{
/*if (ztz->admin < 80 && ztz->ignorerestrictions < 2 && zoneserver_list.IsZoneLocked(ztz->requested_zone_id))
{
ztz->response = 0;
zsc->SendPacket(pack);
return;
}*/
ZoneServer* zs = zoneserver_list.FindByZoneID(ztz->requested_zone_id);
if(zs)
{
// send to the zoneserver hosting the zone for further processing
EQC::Common::PrintF(CP_WORLDSERVER, "Found a zone already booted for %s\n", ztz->name);
zs->SendPacket(pack);
}
else
{
char zonename[16];
strcpy(zonename,Database::Instance()->GetZoneName(ztz->requested_zone_id,true));
if (zoneserver_list.TriggerBootup(zonename))
{
EQC::Common::PrintF(CP_WORLDSERVER, "Successfully booted a zone for %s\n", ztz->name);
// bootup successful, ready to rock
ztz->response = 1;
}
else
{
EQC::Common::PrintF(CP_WORLDSERVER, "FAILED to boot a zone for %s\n", ztz->name);
// bootup failed, send back error code 0
ztz->response = 0;
}
zsc->SendPacket(pack);
}
}
else
{
EQC::Common::PrintF(CP_WORLDSERVER, "Processing ZTZ for ingress to zone for client %s\n", ztz->name);
// Send the response back to the original zoneserver
zsc->SendPacket(pack);
}
return;
}
示例2: SendPacket
bool ZSList::SendPacket(uint32 ZoneID, uint16 instanceID, ServerPacket* pack) {
LinkedListIterator<ZoneServer*> iterator(list);
iterator.Reset();
if(instanceID != 0)
{
while(iterator.MoreElements()) {
if(iterator.GetData()->GetInstanceID() == instanceID) {
ZoneServer* tmp = iterator.GetData();
return(tmp->SendPacket(pack));
}
iterator.Advance();
}
}
else
{
while(iterator.MoreElements()) {
if (iterator.GetData()->GetZoneID() == ZoneID
&& iterator.GetData()->GetInstanceID() == 0) {
ZoneServer* tmp = iterator.GetData();
return(tmp->SendPacket(pack));
}
iterator.Advance();
}
}
return(false);
}
示例3: SendPacket
bool ClientList::SendPacket(const char* to, ServerPacket* pack) {
if (to == 0 || to[0] == 0) {
zoneserver_list.SendPacket(pack);
return true;
}
else if (to[0] == '*') {
// Cant send a packet to a console....
return false;
}
else {
ClientListEntry* cle = FindCharacter(to);
if (cle != nullptr) {
if (cle->Server() != nullptr) {
cle->Server()->SendPacket(pack);
return true;
}
return false;
} else {
ZoneServer* zs = zoneserver_list.FindByName(to);
if (zs != nullptr) {
zs->SendPacket(pack);
return true;
}
return false;
}
}
return false;
}
示例4: handle_rc_relay
void handle_rc_relay(const std::string &method, const std::string &connection_id, const std::string &request_id, const std::vector<std::string> ¶ms) {
std::string error;
std::map<std::string, std::string> res;
uint32 zone_id = 0;
uint32 instance_id = 0;
ZoneServer *zs = nullptr;
if(params.size() < 2) {
error = "Missing zone relay params";
RemoteCallResponse(connection_id, request_id, res, error);
return;
}
zone_id = (uint32)atoi(params[0].c_str());
instance_id = (uint32)atoi(params[1].c_str());
if(!zone_id && !instance_id) {
error = "Zone not booted";
RemoteCallResponse(connection_id, request_id, res, error);
return;
}
if(instance_id) {
zs = zoneserver_list.FindByInstanceID(instance_id);
} else {
zs = zoneserver_list.FindByZoneID(zone_id);
}
if(!zs) {
error = "Zone server not found";
RemoteCallResponse(connection_id, request_id, res, error);
return;
}
uint32 sz = (uint32)(request_id.size() + connection_id.size() + method.size() + 3 + 16);
uint32 p_sz = (uint32)params.size() - 2;
for(uint32 i = 0; i < p_sz; ++i) {
auto ¶m = params[i + 2];
sz += (uint32)param.size();
sz += 5;
}
ServerPacket *pack = new ServerPacket(ServerOP_WIRemoteCall, sz);
pack->WriteUInt32((uint32)request_id.size());
pack->WriteString(request_id.c_str());
pack->WriteUInt32((uint32)connection_id.size());
pack->WriteString(connection_id.c_str());
pack->WriteUInt32((uint32)method.size());
pack->WriteString(method.c_str());
pack->WriteUInt32(p_sz);
for(uint32 i = 0; i < p_sz; ++i) {
auto ¶m = params[i + 2];
pack->WriteUInt32((uint32)param.size());
pack->WriteString(param.c_str());
}
zs->SendPacket(pack);
safe_delete(pack);
}
示例5: ProcessServerOP_ZoneShutdown
void ZoneServer::ProcessServerOP_ZoneShutdown(ServerPacket* pack)
{
ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer;
ZoneServer* zs = 0;
if (s->ZoneServerID != 0)
{
zs = zoneserver_list.FindByID(s->ZoneServerID);
}
else if (s->zoneid != 0)
{
zs = zoneserver_list.FindByZoneID(s->zoneid);
}
else
{
zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, "Error: SOP_ZoneShutdown: neither ID nor name specified");
}
if (zs == 0)
{
zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, "Error: SOP_ZoneShutdown: zoneserver not found");
}
else
{
zs->SendPacket(pack);
}
}
示例6: SendEmoteMessageRaw
void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message) {
if (!message)
return;
ServerPacket* pack = new ServerPacket;
pack->opcode = ServerOP_EmoteMessage;
pack->size = sizeof(ServerEmoteMessage_Struct)+strlen(message)+1;
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, pack->size);
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer;
if (to) {
if (to[0] == '*') {
Console* con = console_list.FindByAccountName(&to[1]);
if (con)
con->SendEmoteMessageRaw(to, to_guilddbid, to_minstatus, type, message);
delete pack;
return;
}
strcpy((char *) sem->to, to);
}
else {
sem->to[0] = 0;
}
sem->guilddbid = to_guilddbid;
sem->minstatus = to_minstatus;
sem->type = type;
strcpy(&sem->message[0], message);
char tempto[64]={0};
if(to)
strn0cpy(tempto,to,64);
pack->Deflate();
if (tempto[0] == 0) {
SendPacket(pack);
if (to_guilddbid == 0)
console_list.SendEmoteMessageRaw(type, message);
}
else {
ZoneServer* zs = FindByName(to);
if (zs != 0)
zs->SendPacket(pack);
else
SendPacket(pack);
}
delete pack;
}
示例7: ProcessServerOP_Uptime
void ZoneServer::ProcessServerOP_Uptime(ServerPacket* pack)
{
if (pack->size != sizeof(ServerUptime_Struct))
{
cout << "Wrong size on ServerOP_Uptime. Got: " << pack->size << ", Expected: " << sizeof(ServerUptime_Struct) << endl;
}
else
{
ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer;
if (sus->zoneserverid == 0)
{
int32 ms = Timer::GetCurrentTime();
int32 days = ms / 86400000;
ms -= days * 86400000;
int32 hours = ms / 3600000;
ms -= hours * 3600000;
int32 minuets = ms / 60000;
ms -= minuets * 60000;
int32 seconds = ms / 1000;
if (days)
{
this->SendEmoteMessage(sus->adminname, 0, 0, "Worldserver Uptime: %02id %02ih %02im %02is", days, hours, minuets, seconds);
}
else if (hours)
{
this->SendEmoteMessage(sus->adminname, 0, 0, "Worldserver Uptime: %02ih %02im %02is", hours, minuets, seconds);
}
else
{
this->SendEmoteMessage(sus->adminname, 0, 0, "Worldserver Uptime: %02im %02is", minuets, seconds);
}
}
else
{
ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid);
if (zs)
{
zs->SendPacket(pack);
}
}
}
}
示例8: EnterWorld
void Client::EnterWorld(bool TryBootup) {
if (zoneID == 0)
return;
ZoneServer* zs = nullptr;
if(instanceID > 0)
{
if(database.VerifyInstanceAlive(instanceID, GetCharID()))
{
if(database.VerifyZoneInstance(zoneID, instanceID))
{
zs = zoneserver_list.FindByInstanceID(instanceID);
}
else
{
instanceID = 0;
zs = nullptr;
database.MoveCharacterToBind(GetCharID());
ZoneUnavail();
return;
}
}
else
{
instanceID = 0;
zs = nullptr;
database.MoveCharacterToBind(GetCharID());
ZoneUnavail();
return;
}
}
else
zs = zoneserver_list.FindByZoneID(zoneID);
const char *zone_name=database.GetZoneName(zoneID, true);
if (zs) {
// warn the world we're comming, so it knows not to shutdown
zs->IncommingClient(this);
}
else {
if (TryBootup) {
clog(WORLD__CLIENT,"Attempting autobootup of %s (%d:%d)",zone_name,zoneID,instanceID);
autobootup_timeout.Start();
pwaitingforbootup = zoneserver_list.TriggerBootup(zoneID, instanceID);
if (pwaitingforbootup == 0) {
clog(WORLD__CLIENT_ERR,"No zoneserver available to boot up.");
ZoneUnavail();
}
return;
}
else {
clog(WORLD__CLIENT_ERR,"Requested zone %s is no running.",zone_name);
ZoneUnavail();
return;
}
}
pwaitingforbootup = 0;
cle->SetChar(charid, char_name);
database.UpdateLiveChar(char_name, GetAccountID());
clog(WORLD__CLIENT,"%s %s (%d:%d)",seencharsel ? "Entering zone" : "Zoning to",zone_name,zoneID,instanceID);
// database.SetAuthentication(account_id, char_name, zone_name, ip);
if (seencharsel) {
if (GetAdmin() < 80 && zoneserver_list.IsZoneLocked(zoneID)) {
clog(WORLD__CLIENT_ERR,"Enter world failed. Zone is locked.");
ZoneUnavail();
return;
}
ServerPacket* pack = new ServerPacket;
pack->opcode = ServerOP_AcceptWorldEntrance;
pack->size = sizeof(WorldToZone_Struct);
pack->pBuffer = new uchar[pack->size];
memset(pack->pBuffer, 0, pack->size);
WorldToZone_Struct* wtz = (WorldToZone_Struct*) pack->pBuffer;
wtz->account_id = GetAccountID();
wtz->response = 0;
zs->SendPacket(pack);
delete pack;
}
else { // if they havent seen character select screen, we can assume this is a zone
// to zone movement, which should be preauthorized before they leave the previous zone
Clearance(1);
}
}
示例9: Process
bool ZoneServer::Process() {
if (!tcpc->Connected())
return false;
if(ls_zboot.Check()){
LSBootUpdate(GetZoneID(), true);
ls_zboot.Disable();
}
ServerPacket *pack = 0;
while((pack = tcpc->PopPacket())) {
_hex(WORLD__ZONE_TRACE,pack->pBuffer,pack->size);
if (!authenticated) {
if (WorldConfig::get()->SharedKey.length() > 0) {
if (pack->opcode == ServerOP_ZAAuth && pack->size == 16) {
uint8 tmppass[16];
MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass);
if (memcmp(pack->pBuffer, tmppass, 16) == 0)
authenticated = true;
else {
struct in_addr in;
in.s_addr = GetIP();
zlog(WORLD__ZONE_ERR,"Zone authorization failed.");
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
Disconnect();
return false;
}
}
else {
struct in_addr in;
in.s_addr = GetIP();
zlog(WORLD__ZONE_ERR,"Zone authorization failed.");
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
Disconnect();
return false;
}
}
else
{
_log(WORLD__ZONE,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access.");
authenticated = true;
}
}
switch(pack->opcode) {
case 0:
break;
case ServerOP_KeepAlive: {
// ignore this
break;
}
case ServerOP_ZAAuth: {
break;
}
case ServerOP_LSZoneBoot:{
if(pack->size==sizeof(ZoneBoot_Struct)){
ZoneBoot_Struct* zbs= (ZoneBoot_Struct*)pack->pBuffer;
SetCompile(zbs->compile_time);
}
break;
}
case ServerOP_GroupInvite: {
if(pack->size != sizeof(GroupInvite_Struct))
break;
GroupInvite_Struct* gis = (GroupInvite_Struct*) pack->pBuffer;
client_list.SendPacket(gis->invitee_name, pack);
break;
}
case ServerOP_GroupFollow: {
if(pack->size != sizeof(ServerGroupFollow_Struct))
break;
ServerGroupFollow_Struct *sgfs = (ServerGroupFollow_Struct *) pack->pBuffer;
client_list.SendPacket(sgfs->gf.name1, pack);
break;
}
case ServerOP_GroupFollowAck: {
if(pack->size != sizeof(ServerGroupFollowAck_Struct))
break;
ServerGroupFollowAck_Struct *sgfas = (ServerGroupFollowAck_Struct *) pack->pBuffer;
client_list.SendPacket(sgfas->Name, pack);
break;
}
case ServerOP_GroupCancelInvite: {
if(pack->size != sizeof(GroupCancel_Struct))
break;
GroupCancel_Struct *gcs = (GroupCancel_Struct *) pack->pBuffer;
client_list.SendPacket(gcs->name1, pack);
break;
}
case ServerOP_GroupIDReq: {
SendGroupIDs();
//.........这里部分代码省略.........
示例10: Process
bool WebInterfaceConnection::Process()
{
if (!stream || !stream->Connected())
return false;
ServerPacket *pack = 0;
while((pack = stream->PopPacket()))
{
if (!authenticated)
{
if (WorldConfig::get()->SharedKey.length() > 0)
{
if (pack->opcode == ServerOP_ZAAuth && pack->size == 16)
{
uint8 tmppass[16];
MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass);
if (memcmp(pack->pBuffer, tmppass, 16) == 0)
authenticated = true;
else
{
struct in_addr in;
in.s_addr = GetIP();
_log(WEB_INTERFACE__ERROR, "WebInterface authorization failed.");
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
Disconnect();
return false;
}
}
else
{
struct in_addr in;
in.s_addr = GetIP();
_log(WEB_INTERFACE__ERROR, "WebInterface authorization failed.");
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
SendPacket(pack);
delete pack;
Disconnect();
return false;
}
}
else
{
_log(WEB_INTERFACE__ERROR, "**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthorized zone access.");
authenticated = true;
}
delete pack;
continue;
}
switch(pack->opcode)
{
case 0:
break;
case ServerOP_KeepAlive:
{
// ignore this
break;
}
case ServerOP_ZAAuth:
{
_log(WEB_INTERFACE__ERROR, "Got authentication from WebInterface when they are already authenticated.");
break;
}
case ServerOP_WIRemoteCall:
{
char *id = nullptr;
char *session_id = nullptr;
char *method = nullptr;
id = new char[pack->ReadUInt32() + 1];
pack->ReadString(id);
session_id = new char[pack->ReadUInt32() + 1];
pack->ReadString(session_id);
method = new char[pack->ReadUInt32() + 1];
pack->ReadString(method);
uint32 param_count = pack->ReadUInt32();
std::vector<std::string> params;
for(uint32 i = 0; i < param_count; ++i) {
char *p = new char[pack->ReadUInt32() + 1];
pack->ReadString(p);
params.push_back(p);
safe_delete_array(p);
}
if (remote_call_methods.count(method) != 0) {
auto f = remote_call_methods[method];
f(method, session_id, id, params);
}
safe_delete_array(id);
safe_delete_array(session_id);
safe_delete_array(method);
//.........这里部分代码省略.........