SyncServerEventSenders.cpp   SyncServerEventSenders.cpp 
skipping to change at line 25 skipping to change at line 25
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "SyncServerEventSenders.hpp" #include "SyncServerEventSenders.hpp"
#include "SyncServer.hpp" #include "SyncServer.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelMovementMgr.hpp"
#include "StelObserver.hpp" #include "StelObserver.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelPropertyMgr.hpp"
using namespace SyncProtocol;
SyncServerEventSender::SyncServerEventSender() SyncServerEventSender::SyncServerEventSender()
: isDirty(false) : isDirty(false)
, server(Q_NULLPTR)
{ {
core = StelApp::getInstance().getCore(); core = StelApp::getInstance().getCore();
} }
void SyncServerEventSender::broadcastMessage(const SyncMessage &msg) void SyncServerEventSender::broadcastMessage(const SyncMessage &msg)
{ {
server->broadcastMessage(msg); server->broadcastMessage(msg);
} }
TimeEventSender::TimeEventSender() TimeEventSender::TimeEventSender()
skipping to change at line 56 skipping to change at line 61
{ {
Time msg; Time msg;
msg.lastTimeSyncTime = core->getMilliSecondsOfLastJDUpdate(); msg.lastTimeSyncTime = core->getMilliSecondsOfLastJDUpdate();
msg.jDay = core->getJDOfLastJDUpdate(); msg.jDay = core->getJDOfLastJDUpdate();
msg.timeRate = core->getTimeRate(); msg.timeRate = core->getTimeRate();
return msg; return msg;
} }
LocationEventSender::LocationEventSender() LocationEventSender::LocationEventSender()
{ {
connect(core,SIGNAL(locationChanged(StelLocation)), this, SLOT(react ToStellariumEvent())); connect(core,SIGNAL(targetLocationChanged(StelLocation)), this, SLOT (reactToStellariumEvent()));
} }
Location LocationEventSender::constructMessage() Location LocationEventSender::constructMessage()
{ {
Location loc; Location loc;
const StelObserver* obs = core->getCurrentObserver(); const StelObserver* obs = core->getCurrentObserver();
//test if the observer is moving (spaceship) //test if the observer is moving (spaceship)
const SpaceShipObserver* sso = qobject_cast<const SpaceShipObserver* >(obs); const SpaceShipObserver* sso = qobject_cast<const SpaceShipObserver* >(obs);
skipping to change at line 99 skipping to change at line 104
Selection msg; Selection msg;
const QList<StelObjectP>& selObj = objMgr->getSelectedObject(); const QList<StelObjectP>& selObj = objMgr->getSelectedObject();
//note: there is no current way to uniquely identify an object //note: there is no current way to uniquely identify an object
//maybe identify by type+name? but it seems this needs some changes //maybe identify by type+name? but it seems this needs some changes
//(StelObject::getType does not correspond directly to StelObjectMod ule::getName) //(StelObject::getType does not correspond directly to StelObjectMod ule::getName)
//even then, some objects (e.g. Nebulas) dont seem to have a name at all! //even then, some objects (e.g. Nebulas) dont seem to have a name at all!
for (QList<StelObjectP>::const_iterator iter=selObj.constBegin();ite r!=selObj.constEnd();++iter) for (QList<StelObjectP>::const_iterator iter=selObj.constBegin();ite r!=selObj.constEnd();++iter)
{ {
msg.selectedObjectNames.append((*iter)->getEnglishName()); msg.selectedObjects.append(qMakePair((*iter)->getType(), (*i ter)->getID()));
} }
return msg; return msg;
} }
StelPropertyEventSender::StelPropertyEventSender()
{
propMgr = StelApp::getInstance().getStelPropertyManager();
connect(propMgr, SIGNAL(stelPropertyChanged(StelProperty*,QVariant))
, this, SLOT(sendStelPropChange(StelProperty*,QVariant)));
}
void StelPropertyEventSender::sendStelPropChange(StelProperty* prop, const
QVariant &val)
{
//only send changes that can be applied on clients
if(prop->isSynchronizable())
{
StelPropertyUpdate msg;
msg.propId = prop->getId();
msg.value = val;
broadcastMessage(msg);
}
}
void StelPropertyEventSender::newClientConnected(SyncRemotePeer &client)
{
//send all current StelProperty values to the client
QList<StelProperty*> propList = propMgr->getAllProperties();
foreach(StelProperty* prop, propList)
{
if(!prop->isSynchronizable())
continue;
StelPropertyUpdate msg;
msg.propId = prop->getId();
msg.value = prop->getValue();
client.writeMessage(msg);
}
}
ViewEventSender::ViewEventSender()
: lastView(0.0)
{
mvMgr = core->getMovementMgr();
}
SyncProtocol::View ViewEventSender::constructMessage()
{
View msg;
Vec3d viewDirJ2000 = mvMgr->getViewDirectionJ2000();
msg.viewAltAz = core->j2000ToAltAz(viewDirJ2000, StelCore::Refractio
nOff);
return msg;
}
void ViewEventSender::update()
{
//do not send view updates when tracking
if(mvMgr->getFlagTracking())
return;
Vec3d viewDir = mvMgr->getViewDirectionJ2000();
viewDir = core->j2000ToAltAz(viewDir, StelCore::RefractionOff);
if(!(qFuzzyCompare(viewDir[0], lastView[0]) && qFuzzyCompare(viewDir
[1], lastView[1]) && qFuzzyCompare(viewDir[2], lastView[2])))
{
lastView = viewDir;
broadcastMessage(constructMessage());
}
}
FovEventSender::FovEventSender()
: lastFov(0.0)
{
mvMgr = core->getMovementMgr();
}
SyncProtocol::Fov FovEventSender::constructMessage()
{
Fov msg;
msg.fov = mvMgr->getCurrentFov();
return msg;
}
void FovEventSender::update()
{
double curFov = mvMgr->getCurrentFov();
if(curFov!=lastFov)
{
lastFov = curFov;
broadcastMessage(constructMessage());
}
}
 End of changes. 6 change blocks. 
2 lines changed or deleted 7 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/