Sirikata
|
#include <EmersonScript.hpp>
Public Member Functions | |
EmersonScript (HostedObjectPtr ho, const String &args, const String &script, JSObjectScriptManager *jMan, JSCtx *ctx) | |
virtual | ~EmersonScript () |
virtual void | start () |
virtual void | stop () |
virtual void | onConnected (SessionEventProviderPtr from, const SpaceObjectReference &name, HostedObject::PresenceToken token) |
Invoked upon connection. | |
virtual void | onDisconnected (SessionEventProviderPtr from, const SpaceObjectReference &name) |
Invoked upon disconnection. | |
void | requestDisconnect (JSPresenceStruct *jspres) |
Time | getHostedTime () |
virtual void | notifyProximateGone (ProxyObjectPtr proximateObject, const SpaceObjectReference &querier) |
virtual void | notifyProximate (ProxyObjectPtr proximateObject, const SpaceObjectReference &querier) |
virtual bool | handleScriptCommRead (const SpaceObjectReference &src, const SpaceObjectReference &dst, const std::string &payload) |
void | handleScriptCommUnreliable (const ODP::Endpoint &src, const ODP::Endpoint &dst, MemoryReference payload) |
Callback for unreliable messages. | |
boost::any | invokeInvokable (std::vector< boost::any > ¶ms, v8::Persistent< v8::Function > function_) |
void | invokeCallbackInContext (Liveness::Token alive, v8::Persistent< v8::Function > cb, JSContextStruct *jscontext) |
void | handlePresCallback (v8::Handle< v8::Function > funcToCall, JSContextStruct *jscont, JSPresenceStruct *jspres) |
v8::Handle< v8::Value > | restorePresence (PresStructRestoreParams &psrp, JSContextStruct *jsctx) |
void | fireProxEvent (const SpaceObjectReference &localPresSporef, JSVisibleStruct *jsvis, JSContextStruct *jscont, bool isGone) |
bool | valid () const |
Returns true if this script is valid, i.e. | |
void | killOtherPresences (JSPresVec &jspresVec) |
This function runs through the entire list of presences associated with this JSObjectScript, and then frees those that are not part of that vector. | |
v8::Handle< v8::Value > | killEntity (JSContextStruct *jscont) |
void | sendMessageToEntityUnreliable (const SpaceObjectReference &receiver, const SpaceObjectReference &from, const std::string &msgBody) |
Sends a message over the odp port from local presence that has sporef from to some other presence in world with sporef receiver. | |
v8::Local< v8::Object > | presToVis (JSPresenceStruct *jspres, JSContextStruct *jscont) |
v8::Handle< v8::Value > | create_event (v8::Persistent< v8::Function > &cb, JSContextStruct *jscont) |
v8::Handle< v8::Value > | create_timeout (double period, v8::Persistent< v8::Function > &cb, JSContextStruct *jscont) |
Set a timeout with a callback. | |
v8::Handle< v8::Value > | create_timeout (double period, v8::Persistent< v8::Function > &cb, uint32 contID, double timeRemaining, bool isSuspended, bool isCleared, JSContextStruct *jscont) |
void | registerFixupSuspendable (JSSuspendable *jssuspendable, uint32 contID) |
void | create_entity (EntityCreateInfo &eci) |
create a new entity at the run time | |
virtual void | registerContextForClear (JSContextStruct *jscont) |
v8::Local< v8::Object > | createVisibleWeakPersistent (const SpaceObjectReference &presID, const SpaceObjectReference &visibleObj, JSVisibleDataPtr addParams) |
Creates a JSVisibleStruct and wraps it in a persistent v8 object that is returned. | |
v8::Local< v8::Object > | createVisibleWeakPersistent (const SpaceObjectReference &visibleObj, JSVisibleDataPtr addParams) |
void | setLocation (const SpaceObjectReference sporef, const TimedMotionVector3f &loc) |
void | setOrientation (const SpaceObjectReference sporef, const TimedMotionQuaternion &orient) |
void | setBounds (const SpaceObjectReference sporef, const BoundingSphere3f &bounds) |
void | setVisual (const SpaceObjectReference sporef, const std::string &newMeshString) |
String | getQuery (const SpaceObjectReference &sporef) const |
void | setQueryFunction (const SpaceObjectReference sporef, const String &query) |
void | setPhysicsFunction (const SpaceObjectReference sporef, const String &newPhysicsString) |
v8::Handle< v8::Value > | findVisible (const SpaceObjectReference &proximateObj) |
v8::Local< v8::Object > | wrapPresence (JSPresenceStruct *presToWrap, v8::Persistent< v8::Context > *ctxToWrapIn) |
Sirikata::JS::JSInvokableObject::JSInvokableObjectInt * | runSimulation (const SpaceObjectReference &sporef, const String &simname) |
v8::Handle< v8::Value > | requestReset (JSContextStruct *jscont, const std::map< SpaceObjectReference, std::vector< SpaceObjectReference > > &proxSetVis) |
void | deletePres (JSPresenceStruct *toDelete) |
Timers and context suspendables are killed and deleted in contexts. | |
void | resetPresence (JSPresenceStruct *jspresStruct) |
This function adds jspresStruct to mPresences map. | |
JSObjectScriptManager * | manager () const |
JSContextStruct * | rootContext () const |
EmersonHttpPtr | getEmersonHttpPtr () |
Contexts are allowed to initiate http requests. | |
v8::Handle< v8::Value > | sendSandbox (const String &msgToSend, uint32 senderID, uint32 receiverID) |
msgToSend contains a serialized v8 object that will be sent from sandbox with id sendingSandbox to sandbox with id receivingSandbox. | |
virtual void | postCallbackChecks () |
Public Attributes | |
JSVisibleManager | jsVisMan |
HostedObjectPtr | mParent |
Private Types | |
typedef std::map < SpaceObjectReference, ODP::Port * > | MessagingPortMap |
typedef std::map < SpaceObjectReference, JSPresenceStruct * > | PresenceMap |
typedef PresenceMap::iterator | PresenceMapIter |
typedef std::vector < JSPresenceStruct * > | PresenceVec |
typedef std::vector< std::pair < String, SpaceObjectReference > > | SimVec |
Private Member Functions | |
void | postDestroy (Liveness::Token alive) |
void | unsubscribePresenceEvents (const SpaceObjectReference &name) |
void | removePresenceData (const SpaceObjectReference &sporefToDelete) |
v8::Local< v8::Object > | createVisibleWeakPersistent (JSVisibleStruct *jsvis) |
void | killScript () |
void | resetScript () |
bool | handleScriptCommRead (const SpaceObjectReference &src, const SpaceObjectReference &dst, Sirikata::JS::Protocol::JSMessage js_msg) |
HostedObject::PresenceToken | incrementPresenceToken () |
void | printStackFrame (std::stringstream &, v8::Local< v8::StackFrame >) |
JSPresenceStruct * | addConnectedPresence (const SpaceObjectReference &sporef, HostedObject::PresenceToken token) |
void | processSandboxMessage (String msgToSend, uint32 senderID, uint32 receiverID, Liveness::Token alive) |
Tries to decode string as a v8 object. | |
void | finishContextClear (JSContextStruct *jscont) |
Removes jscont from context map and tells it to finish its clear methods. | |
JSPresenceStruct * | findPresence (const SpaceObjectReference &sporef) |
void | callbackUnconnected (ProxyObjectPtr proxy, HostedObject::PresenceToken token) |
void | iOnDisconnected (SessionEventProviderPtr from, const SpaceObjectReference &name, Liveness::Token alive) |
void | eCreateEntityFinish (ObjectHost *oh, EntityCreateInfo &eci) |
void | iStop (Liveness::Token alive, bool letDie) |
void | iHandleScriptCommRead (const SpaceObjectReference &src, const SpaceObjectReference &dst, const String &payload, Liveness::Token alive) |
void | iHandleScriptCommUnreliable (const ODP::Endpoint &src, const ODP::Endpoint &dst, MemoryReference payload, Liveness::Token alive) |
void | mainStrandCompletePresConnect (Location newLoc, BoundingSphere3f bs, PresStructRestoreParams psrp, HostedObject::PresenceToken presToke, Liveness::Token alive) |
void | iNotifyProximateGone (ProxyObjectPtr proximateObject, const SpaceObjectReference &querier, Liveness::Token alive) |
void | iResetProximateHelper (JSVisibleStruct *proxVis, const SpaceObjectReference &proxTo) |
void | iNotifyProximate (ProxyObjectPtr proximateObject, const SpaceObjectReference &querier, Liveness::Token alive) |
void | iOnConnected (SessionEventProviderPtr from, const SpaceObjectReference &name, HostedObject::PresenceToken token, bool duringInit, Liveness::Token alive) |
void | iInvokeInvokable (std::vector< boost::any > ¶ms, v8::Persistent< v8::Function > function_, Liveness::Token alive) |
Private Attributes | |
bool | mHandlingEvent |
bool | mResetting |
bool | mKilling |
MessagingPortMap | mMessagingPortMap |
HostedObject::PresenceToken | presenceToken |
PresenceMap | mPresences |
std::map< SpaceObjectReference, std::vector< JSVisibleStruct * > > | resettingVisiblesResultSet |
When we are resetting, we want to replay all the visibles that presences had received in their prox result set. | |
PresenceVec | mUnconnectedPresences |
std::vector< JSContextStruct * > | contextsToClear |
EmersonHttpPtr | emHttpPtr |
SimVec | mSimulations |
typedef std::map<SpaceObjectReference, ODP::Port*> Sirikata::JS::EmersonScript::MessagingPortMap [private] |
typedef std::map<SpaceObjectReference, JSPresenceStruct*> Sirikata::JS::EmersonScript::PresenceMap [private] |
typedef PresenceMap::iterator Sirikata::JS::EmersonScript::PresenceMapIter [private] |
typedef std::vector<JSPresenceStruct*> Sirikata::JS::EmersonScript::PresenceVec [private] |
typedef std::vector< std::pair<String,SpaceObjectReference> > Sirikata::JS::EmersonScript::SimVec [private] |
Sirikata::JS::EmersonScript::EmersonScript | ( | HostedObjectPtr | ho, |
const String & | args, | ||
const String & | script, | ||
JSObjectScriptManager * | jMan, | ||
JSCtx * | ctx | ||
) |
References Sirikata::OptionValue::as(), Sirikata::HostedObject::DEFAULT_PRESENCE_TOKEN, Sirikata::Logging::fatal, Sirikata::JS::JSObjectScriptManager::getOptions(), Sirikata::JS::JSCtx::initialize(), Sirikata::JS::JSObjectScript::initialize(), iOnConnected(), JSLOG, Sirikata::Liveness::livenessToken(), Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mIsolate, Sirikata::JS::JSObjectScript::mManager, mParent, and Sirikata::OptionSet::referenceOption().
Sirikata::JS::EmersonScript::~EmersonScript | ( | ) | [virtual] |
JSPresenceStruct * Sirikata::JS::EmersonScript::addConnectedPresence | ( | const SpaceObjectReference & | sporef, |
HostedObject::PresenceToken | token | ||
) | [private] |
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::mContext, Sirikata::JS::JSObjectScript::mCtx, and mPresences.
Referenced by iOnConnected().
void Sirikata::JS::EmersonScript::callbackUnconnected | ( | ProxyObjectPtr | proxy, |
HostedObject::PresenceToken | token | ||
) | [private] |
References Sirikata::JS::JSPresenceStruct::connect(), EMERSCRIPT_SERIAL_CHECK, Sirikata::Logging::error, JSLOG, mPresences, and mUnconnectedPresences.
Referenced by iOnConnected().
void Sirikata::JS::EmersonScript::create_entity | ( | EntityCreateInfo & | eci | ) |
create a new entity at the run time
References eCreateEntityFinish(), EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSCtx::mainStrand, Sirikata::JS::JSObjectScript::mCtx, mParent, and Sirikata::Network::IOStrand::post().
v8::Handle< v8::Value > Sirikata::JS::EmersonScript::create_event | ( | v8::Persistent< v8::Function > & | cb, |
JSContextStruct * | jscont | ||
) |
lkjs; FIXME: what happens if jscont gets deleted before invokeCallbackInContext is called; or suspended in between; probably should pass context id through invokeCallbackInContext;
References EMERSCRIPT_SERIAL_CHECK, invokeCallbackInContext(), JSLOG, Sirikata::Liveness::livenessToken(), Sirikata::JS::JSObjectScript::mCtx, mParent, Sirikata::JS::JSCtx::objStrand, and Sirikata::Logging::warn.
v8::Handle< v8::Value > Sirikata::JS::EmersonScript::create_timeout | ( | double | period, |
v8::Persistent< v8::Function > & | cb, | ||
JSContextStruct * | jscont | ||
) |
Set a timeout with a callback.
References EMERSCRIPT_SERIAL_CHECK, and Sirikata::JS::JSContextStruct::getContextID().
v8::Handle< v8::Value > Sirikata::JS::EmersonScript::create_timeout | ( | double | period, |
v8::Persistent< v8::Function > & | cb, | ||
uint32 | contID, | ||
double | timeRemaining, | ||
bool | isSuspended, | ||
bool | isCleared, | ||
JSContextStruct * | jscont | ||
) |
lkjs; FIXME: need to update JSTimerStruct to use JSCtx and objstrand.
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mTimerTemplate, Sirikata::JS::JSTimerStruct::setPersistentObject(), TIMER_JSTIMERSTRUCT_FIELD, Sirikata::JS::JSTimerStruct::timerWeakReferenceCleanup(), and TYPEID_FIELD.
v8::Local< v8::Object > Sirikata::JS::EmersonScript::createVisibleWeakPersistent | ( | const SpaceObjectReference & | presID, |
const SpaceObjectReference & | visibleObj, | ||
JSVisibleDataPtr | addParams | ||
) |
Creates a JSVisibleStruct and wraps it in a persistent v8 object that is returned.
{SpaceObjectReference} | visibleObj Will make a JSVisibleStruct out of this spaceobjectreference. |
{JSVisibleDataPtr} | addParams If don't have a proxy object in the world with sporef visibleObj, will try to fill in JSVisibleStruct data with these values (note: if NULL), fills in default values. |
Referenced by createVisibleWeakPersistent(), Sirikata::JS::JSSerializer::deserializeObjectInternal(), findVisible(), fireProxEvent(), iHandleScriptCommRead(), and presToVis().
v8::Local< v8::Object > Sirikata::JS::EmersonScript::createVisibleWeakPersistent | ( | JSVisibleStruct * | jsvis | ) | [private] |
v8::Local< v8::Object > Sirikata::JS::EmersonScript::createVisibleWeakPersistent | ( | const SpaceObjectReference & | visibleObj, |
JSVisibleDataPtr | addParams | ||
) |
void Sirikata::JS::EmersonScript::deletePres | ( | JSPresenceStruct * | toDelete | ) |
Timers and context suspendables are killed and deleted in contexts.
However, presences are also stored in EmersonScript, and EmersonScript must be told to kill them and remove them.
And JSPresences, we need to remove from our list of presences and ask hosted object to remove it.
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSPresenceStruct::getIsConnected(), Sirikata::JS::JSPositionListener::getSporef(), mParent, mUnconnectedPresences, Sirikata::SpaceObjectReference::object(), removePresenceData(), and Sirikata::SpaceObjectReference::space().
Referenced by Sirikata::JS::JSContextStruct::struct_deregisterSuspendable().
void Sirikata::JS::EmersonScript::eCreateEntityFinish | ( | ObjectHost * | oh, |
EntityCreateInfo & | eci | ||
) | [private] |
References Sirikata::ObjectHost::createObject(), Sirikata::JS::EntityCreateInfo::loc, Sirikata::JS::EntityCreateInfo::mesh, obj, Sirikata::JS::EntityCreateInfo::physics, Sirikata::JS::EntityCreateInfo::query, Sirikata::JS::EntityCreateInfo::scale, Sirikata::JS::EntityCreateInfo::scriptContents, Sirikata::JS::EntityCreateInfo::scriptOpts, Sirikata::JS::EntityCreateInfo::scriptType, and Sirikata::JS::EntityCreateInfo::space.
Referenced by create_entity().
JSPresenceStruct* Sirikata::JS::EmersonScript::findPresence | ( | const SpaceObjectReference & | sporef | ) | [private] |
v8::Handle< v8::Value > Sirikata::JS::EmersonScript::findVisible | ( | const SpaceObjectReference & | proximateObj | ) |
void Sirikata::JS::EmersonScript::finishContextClear | ( | JSContextStruct * | jscont | ) | [private] |
Removes jscont from context map and tells it to finish its clear methods.
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSContextStruct::finishClear(), and Sirikata::JS::JSObjectScript::mContStructMap.
Referenced by iHandleScriptCommRead(), and registerContextForClear().
void Sirikata::JS::EmersonScript::fireProxEvent | ( | const SpaceObjectReference & | localPresSporef, |
JSVisibleStruct * | jsvis, | ||
JSContextStruct * | jscont, | ||
bool | isGone | ||
) |
{sporef} | localPresSporef The space object reference for the local presence for which a visible has either moved into its prox set or out of its prox set. |
{JSVisibleStruct*} | jsvis The visible struct associated with the presence that moved into or out of local presence's prox set. |
bool} | isGone True if trying to fire a proximity removal event, false if trying to fire a proximity added event. |
Enters context associated with jscontextStruct, and fires either its onProxAdded or onProxRemoved callback function.
References createVisibleWeakPersistent(), Sirikata::Logging::detailed, EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::invokeCallback(), JSLOG, Sirikata::JS::JSContextStruct::mContext, Sirikata::JS::JSObjectScript::mEvalContextStack, postCallbackChecks(), Sirikata::JS::printException(), Sirikata::JS::JSContextStruct::proxAddedFunc, Sirikata::JS::JSContextStruct::proxRemovedFunc, and Sirikata::SpaceObjectReference::toString().
EmersonHttpPtr Sirikata::JS::EmersonScript::getEmersonHttpPtr | ( | ) | [inline] |
Contexts are allowed to initiate http requests.
To do so, they should get a copy of each EmersonScript's httpPtr and make requests directly from there. Similarly, in contexts' destructors, they should also notify emHttpPtr that the context was destroyed.
References emHttpPtr.
Referenced by Sirikata::JS::JSContextStruct::finishClear(), and Sirikata::JS::JSContextStruct::httpRequest().
Time Sirikata::JS::EmersonScript::getHostedTime | ( | ) |
References mParent.
Referenced by Sirikata::JS::JSPositionListener::getOrientation(), Sirikata::JS::JSPositionListener::getPosition(), Sirikata::JS::JSPresenceStruct::setOrientationFunction(), Sirikata::JS::JSPresenceStruct::setOrientationVelFunction(), Sirikata::JS::JSPresenceStruct::struct_setPosition(), and Sirikata::JS::JSPresenceStruct::struct_setVelocity().
String Sirikata::JS::EmersonScript::getQuery | ( | const SpaceObjectReference & | sporef | ) | const |
References mParent, Sirikata::SpaceObjectReference::object(), and Sirikata::SpaceObjectReference::space().
Referenced by Sirikata::JS::JSPresenceStruct::getQuery().
void Sirikata::JS::EmersonScript::handlePresCallback | ( | v8::Handle< v8::Function > | funcToCall, |
JSContextStruct * | jscont, | ||
JSPresenceStruct * | jspres | ||
) |
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::invokeCallback(), Sirikata::JS::JSObjectScript::isStopped(), JSLOG, Sirikata::JS::JSContextStruct::mContext, postCallbackChecks(), Sirikata::Logging::warn, and wrapPresence().
Referenced by Sirikata::JS::JSPresenceStruct::callConnectedCallback(), Sirikata::JS::JSContextStruct::checkContextConnectCallback(), and Sirikata::JS::JSContextStruct::checkContextDisconnectCallback().
virtual bool Sirikata::JS::EmersonScript::handleScriptCommRead | ( | const SpaceObjectReference & | src, |
const SpaceObjectReference & | dst, | ||
const std::string & | payload | ||
) | [virtual] |
Implements Sirikata::JS::EmersonMessagingManager.
Referenced by iHandleScriptCommUnreliable().
bool Sirikata::JS::EmersonScript::handleScriptCommRead | ( | const SpaceObjectReference & | src, |
const SpaceObjectReference & | dst, | ||
Sirikata::JS::Protocol::JSMessage | js_msg | ||
) | [private] |
void Sirikata::JS::EmersonScript::handleScriptCommUnreliable | ( | const ODP::Endpoint & | src, |
const ODP::Endpoint & | dst, | ||
MemoryReference | payload | ||
) |
Callback for unreliable messages.
Used for unreliable messages.
Payload should be able to be parsed into JS::Proctocol::JSMessage. If it can be, and deserialization is successful, processes the scripting message. (via deserializeMsgAndDispatch.)
References iHandleScriptCommUnreliable(), Sirikata::JS::JSObjectScript::isStopped(), JSLOG, Sirikata::Liveness::livenessToken(), Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::objStrand, and Sirikata::Logging::warn.
Referenced by iOnConnected().
void Sirikata::JS::EmersonScript::iHandleScriptCommRead | ( | const SpaceObjectReference & | src, |
const SpaceObjectReference & | dst, | ||
const String & | payload, | ||
Liveness::Token | alive | ||
) | [private] |
References Sirikata::JS::JSContextStruct::canReceiveMessagesFor(), contextsToClear, createVisibleWeakPersistent(), Sirikata::JS::JSSerializer::deserializeMessage(), Sirikata::JS::JSSerializer::deserializeObject(), EMERSCRIPT_SERIAL_CHECK, Sirikata::Logging::error, finishContextClear(), Sirikata::JS::JSObjectScript::invokeCallback(), Sirikata::JS::JSObjectScript::isStopped(), JSLOG, Sirikata::JS::JSContextStruct::mContext, Sirikata::JS::JSObjectScript::mContStructMap, Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSObjectScript::mEvalContextStack, mHandlingEvent, Sirikata::JS::JSCtx::mIsolate, Sirikata::SpaceObjectReference::object(), postCallbackChecks(), Sirikata::JS::JSContextStruct::presenceMessageCallback, Sirikata::SpaceObjectReference::space(), Sirikata::SpaceObjectReference::toString(), and Sirikata::Logging::warn.
void Sirikata::JS::EmersonScript::iHandleScriptCommUnreliable | ( | const ODP::Endpoint & | src, |
const ODP::Endpoint & | dst, | ||
MemoryReference | payload, | ||
Liveness::Token | alive | ||
) | [private] |
References Sirikata::DataReference< T >::data(), EMERSCRIPT_SERIAL_CHECK, handleScriptCommRead(), Sirikata::JS::JSObjectScript::isStopped(), JSLOG, Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mIsolate, Sirikata::ODP::Endpoint::object(), Sirikata::DataReference< T >::size(), Sirikata::XDP::Endpoint< IdentifierType >::space(), and Sirikata::Logging::warn.
Referenced by handleScriptCommUnreliable().
void Sirikata::JS::EmersonScript::iInvokeInvokable | ( | std::vector< boost::any > & | params, |
v8::Persistent< v8::Function > | function_, | ||
Liveness::Token | alive | ||
) | [private] |
FIXME: lkjs All invokables are executed from the root context. This is incorrect.
References Sirikata::JS::InvokableUtil::AnyToV8(), Sirikata::JS::JSObjectScript::context(), EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::invokeCallback(), Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mIsolate, and rootContext().
Referenced by invokeInvokable().
HostedObject::PresenceToken Sirikata::JS::EmersonScript::incrementPresenceToken | ( | ) | [private] |
References Sirikata::HostedObject::DEFAULT_PRESENCE_TOKEN, EMERSCRIPT_SERIAL_CHECK, and presenceToken.
Referenced by restorePresence().
void Sirikata::JS::EmersonScript::iNotifyProximate | ( | ProxyObjectPtr | proximateObject, |
const SpaceObjectReference & | querier, | ||
Liveness::Token | alive | ||
) | [private] |
void Sirikata::JS::EmersonScript::iNotifyProximateGone | ( | ProxyObjectPtr | proximateObject, |
const SpaceObjectReference & | querier, | ||
Liveness::Token | alive | ||
) | [private] |
References Sirikata::JS::JSVisibleManager::createVisStruct(), Sirikata::Logging::detailed, EMERSCRIPT_SERIAL_CHECK, JSLOG, jsVisMan, Sirikata::JS::JSObjectScript::mContStructMap, Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mIsolate, and Sirikata::Logging::warn.
Referenced by notifyProximateGone().
void Sirikata::JS::EmersonScript::invokeCallbackInContext | ( | Liveness::Token | alive, |
v8::Persistent< v8::Function > | cb, | ||
JSContextStruct * | jscontext | ||
) |
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::invokeCallback(), Sirikata::JS::JSObjectScript::mContext, Sirikata::JS::JSContextStruct::mContext, Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mIsolate, and postCallbackChecks().
Referenced by create_event(), and Sirikata::JS::JSTimerStruct::iEvaluateCallback().
boost::any Sirikata::JS::EmersonScript::invokeInvokable | ( | std::vector< boost::any > & | params, |
v8::Persistent< v8::Function > | function_ | ||
) |
void Sirikata::JS::EmersonScript::iOnConnected | ( | SessionEventProviderPtr | from, |
const SpaceObjectReference & | name, | ||
HostedObject::PresenceToken | token, | ||
bool | duringInit, | ||
Liveness::Token | alive | ||
) | [private] |
References addConnectedPresence(), callbackUnconnected(), Sirikata::JS::JSContextStruct::checkContextConnectCallback(), Sirikata::HostedObject::DEFAULT_PRESENCE_TOKEN, EMERSCRIPT_SERIAL_CHECK, EMERSON_UNRELIABLE_COMMUNICATION_PORT, handleScriptCommUnreliable(), Sirikata::JS::JSVisibleManager::iOnCreateProxy(), jsVisMan, Sirikata::JS::JSObjectScript::mContext, Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mIsolate, mMessagingPortMap, mParent, Sirikata::SpaceObjectReference::object(), Sirikata::JS::EmersonMessagingManager::presenceConnected(), Sirikata::XDP::Port< EndpointType >::receive(), and Sirikata::SpaceObjectReference::space().
Referenced by EmersonScript(), and onConnected().
void Sirikata::JS::EmersonScript::iOnDisconnected | ( | SessionEventProviderPtr | from, |
const SpaceObjectReference & | name, | ||
Liveness::Token | alive | ||
) | [private] |
References EMERSCRIPT_SERIAL_CHECK, Sirikata::Logging::error, Sirikata::JS::JSPresenceStruct::handleDisconnectedCallback(), JSLOG, Sirikata::JS::JSPresenceStruct::markDisconnected(), Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mIsolate, mPresences, Sirikata::JS::EmersonMessagingManager::presenceDisconnected(), and unsubscribePresenceEvents().
Referenced by onDisconnected().
void Sirikata::JS::EmersonScript::iResetProximateHelper | ( | JSVisibleStruct * | proxVis, |
const SpaceObjectReference & | proxTo | ||
) | [private] |
References Sirikata::JS::JSObjectScript::mContStructMap.
Referenced by resetScript().
void Sirikata::JS::EmersonScript::iStop | ( | Liveness::Token | alive, |
bool | letDie | ||
) | [private] |
Reimplemented from Sirikata::JS::JSObjectScript.
References Sirikata::JS::JSVisibleManager::clearVisibles(), EMERSCRIPT_SERIAL_CHECK, jsVisMan, Sirikata::Liveness::letDie(), Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mIsolate, mMessagingPortMap, mParent, mPresences, mSimulations, Sirikata::JS::JSCtx::stop(), and unsubscribePresenceEvents().
Referenced by killScript(), stop(), and ~EmersonScript().
v8::Handle< v8::Value > Sirikata::JS::EmersonScript::killEntity | ( | JSContextStruct * | jscont | ) |
References EMERSCRIPT_SERIAL_CHECK, mKilling, and rootContext().
void Sirikata::JS::EmersonScript::killOtherPresences | ( | JSPresVec & | jspresVec | ) |
This function runs through the entire list of presences associated with this JSObjectScript, and then frees those that are not part of that vector.
void Sirikata::JS::EmersonScript::killScript | ( | ) | [private] |
void Sirikata::JS::EmersonScript::mainStrandCompletePresConnect | ( | Location | newLoc, |
BoundingSphere3f | bs, | ||
PresStructRestoreParams | psrp, | ||
HostedObject::PresenceToken | presToke, | ||
Liveness::Token | alive | ||
) | [private] |
References Sirikata::JS::PresStructRestoreParams::mesh, mParent, Sirikata::SpaceObjectReference::object(), Sirikata::JS::PresStructRestoreParams::physics, Sirikata::JS::PresStructRestoreParams::query, Sirikata::SpaceObjectReference::space(), and Sirikata::JS::PresStructRestoreParams::sporef.
Referenced by restorePresence().
JSObjectScriptManager* Sirikata::JS::EmersonScript::manager | ( | ) | const [inline] |
Reimplemented from Sirikata::JS::JSObjectScript.
References Sirikata::JS::JSObjectScript::mManager.
Referenced by Sirikata::JS::JSPositionListener::eLoadMesh().
void Sirikata::JS::EmersonScript::notifyProximate | ( | ProxyObjectPtr | proximateObject, |
const SpaceObjectReference & | querier | ||
) | [virtual] |
void Sirikata::JS::EmersonScript::notifyProximateGone | ( | ProxyObjectPtr | proximateObject, |
const SpaceObjectReference & | querier | ||
) | [virtual] |
void Sirikata::JS::EmersonScript::onConnected | ( | SessionEventProviderPtr | from, |
const SpaceObjectReference & | name, | ||
HostedObject::PresenceToken | token | ||
) | [virtual] |
Invoked upon connection.
from | the SessionEventProvider the event originates from |
name | the name of the object in the space |
Reimplemented from Sirikata::SessionEventListener.
References iOnConnected(), Sirikata::Liveness::livenessToken(), Sirikata::JS::JSObjectScript::mCtx, and Sirikata::JS::JSCtx::objStrand.
void Sirikata::JS::EmersonScript::onDisconnected | ( | SessionEventProviderPtr | from, |
const SpaceObjectReference & | name | ||
) | [virtual] |
Invoked upon disconnection.
from | the SessionEventProvider the event originates from |
name | the name of the object in the space |
Reimplemented from Sirikata::SessionEventListener.
References iOnDisconnected(), Sirikata::Liveness::livenessToken(), Sirikata::JS::JSObjectScript::mCtx, and Sirikata::JS::JSCtx::objStrand.
void Sirikata::JS::EmersonScript::postCallbackChecks | ( | ) | [virtual] |
Reimplemented from Sirikata::JS::JSObjectScript.
References EMERSCRIPT_SERIAL_CHECK, killScript(), mKilling, mResetting, and resetScript().
Referenced by fireProxEvent(), handlePresCallback(), Sirikata::JS::JSPositionListener::iFinishLoadMesh(), iHandleScriptCommRead(), invokeCallbackInContext(), and processSandboxMessage().
void Sirikata::JS::EmersonScript::postDestroy | ( | Liveness::Token | alive | ) | [private] |
References mParent.
Referenced by killScript().
v8::Local< v8::Object > Sirikata::JS::EmersonScript::presToVis | ( | JSPresenceStruct * | jspres, |
JSContextStruct * | jscont | ||
) |
void Sirikata::JS::EmersonScript::printStackFrame | ( | std::stringstream & | , |
v8::Local< v8::StackFrame > | |||
) | [private] |
Reimplemented from Sirikata::JS::JSObjectScript.
void Sirikata::JS::EmersonScript::processSandboxMessage | ( | String | msgToSend, |
uint32 | senderID, | ||
uint32 | receiverID, | ||
Liveness::Token | alive | ||
) | [private] |
Tries to decode string as a v8 object.
Lookup senderID and receiverID in mContStructMap to find associated JSContextStructs. If they don't exist, silently drop. If they do, then check if sender has a callback for sandbox messages defined on it. If it does, then call it with the deserialized message object in it.
References CONTEXT_FIELD_CONTEXT_STRUCT, CONTEXT_TYPEID_STRING, Sirikata::JS::JSSerializer::deserializeMessage(), Sirikata::JS::JSSerializer::deserializeObject(), EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::invokeCallback(), JSLOG, Sirikata::JS::JSContextStruct::mContext, Sirikata::JS::JSCtx::mContextTemplate, Sirikata::JS::JSObjectScript::mContStructMap, Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSObjectScript::mEvalContextStack, mHandlingEvent, Sirikata::JS::JSCtx::mIsolate, Sirikata::JS::JSContextStruct::mParentContext, postCallbackChecks(), Sirikata::JS::JSContextStruct::sandboxMessageCallback, TYPEID_FIELD, and Sirikata::Logging::warn.
Referenced by sendSandbox().
void Sirikata::JS::EmersonScript::registerContextForClear | ( | JSContextStruct * | jscont | ) | [virtual] |
Reimplemented from Sirikata::JS::JSObjectScript.
References contextsToClear, EMERSCRIPT_SERIAL_CHECK, finishContextClear(), and mHandlingEvent.
void Sirikata::JS::EmersonScript::registerFixupSuspendable | ( | JSSuspendable * | jssuspendable, |
uint32 | contID | ||
) |
References EMERSCRIPT_SERIAL_CHECK, and Sirikata::JS::JSObjectScript::toFixup.
Referenced by Sirikata::JS::JSPresenceStruct::JSPresenceStruct(), and Sirikata::JS::JSTimerStruct::JSTimerStruct().
void Sirikata::JS::EmersonScript::removePresenceData | ( | const SpaceObjectReference & | sporefToDelete | ) | [private] |
References EMERSCRIPT_SERIAL_CHECK, mMessagingPortMap, and mPresences.
Referenced by deletePres().
void Sirikata::JS::EmersonScript::requestDisconnect | ( | JSPresenceStruct * | jspres | ) |
v8::Handle< v8::Value > Sirikata::JS::EmersonScript::requestReset | ( | JSContextStruct * | jscont, |
const std::map< SpaceObjectReference, std::vector< SpaceObjectReference > > & | proxSetVis | ||
) |
{JSContextStruct} | jscont: just checks to ensure that jscont is root sandbox before calling reset. (Otherwise, throws error.) |
proxSetVis | : When we reset, we want to be able to replay all the visibles in an entity's prox result set. The key of this map is the visible whose prox set is contained in the value of the map (ie in the vector). |
References Sirikata::JS::JSVisibleManager::createVisStruct(), EMERSCRIPT_SERIAL_CHECK, jsVisMan, Sirikata::JS::JSObjectScript::mContext, mResetting, and resettingVisiblesResultSet.
void Sirikata::JS::EmersonScript::resetPresence | ( | JSPresenceStruct * | jspresStruct | ) |
This function adds jspresStruct to mPresences map.
Then, calls the onPresence added function.
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSPositionListener::getSporef(), and mPresences.
void Sirikata::JS::EmersonScript::resetScript | ( | ) | [private] |
v8::Handle< v8::Value > Sirikata::JS::EmersonScript::restorePresence | ( | PresStructRestoreParams & | psrp, |
JSContextStruct * | jsctx | ||
) |
References EMERSCRIPT_SERIAL_CHECK, Sirikata::Nullable< nullable >::getValue(), incrementPresenceToken(), Sirikata::JS::PresStructRestoreParams::isConnected, Sirikata::Nullable< nullable >::isNull(), Sirikata::Liveness::livenessToken(), Sirikata::JS::JSCtx::mainStrand, mainStrandCompletePresConnect(), Sirikata::JS::JSContextStruct::mContext, Sirikata::JS::JSObjectScript::mCtx, mParent, mPresences, mUnconnectedPresences, Sirikata::JS::PresStructRestoreParams::orient, Sirikata::JS::PresStructRestoreParams::orientTime, Sirikata::JS::PresStructRestoreParams::orientVelocity, position, Sirikata::JS::PresStructRestoreParams::position, Sirikata::JS::PresStructRestoreParams::positionTime, Sirikata::Network::IOStrand::post(), Sirikata::JS::PresStructRestoreParams::scale, Sirikata::JS::PresStructRestoreParams::sporef, Sirikata::Quaternion::toAngleAxis(), Sirikata::JS::PresStructRestoreParams::velocity, and wrapPresence().
JSContextStruct* Sirikata::JS::EmersonScript::rootContext | ( | ) | const [inline] |
Reimplemented from Sirikata::JS::JSObjectScript.
References Sirikata::JS::JSObjectScript::mContext.
Referenced by iInvokeInvokable(), and killEntity().
JSInvokableObject::JSInvokableObjectInt * Sirikata::JS::EmersonScript::runSimulation | ( | const SpaceObjectReference & | sporef, |
const String & | simname | ||
) |
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::mCtx, mParent, and mSimulations.
Referenced by Sirikata::JS::JSPresenceStruct::runSimulation().
void Sirikata::JS::EmersonScript::sendMessageToEntityUnreliable | ( | const SpaceObjectReference & | receiver, |
const SpaceObjectReference & | from, | ||
const std::string & | msgBody | ||
) |
Sends a message over the odp port from local presence that has sporef from to some other presence in world with sporef receiver.
Gets port to send over as value of mMessagingPortMap associated with key from.
References EMERSCRIPT_SERIAL_CHECK, EMERSON_UNRELIABLE_COMMUNICATION_PORT, Sirikata::Logging::error, JSLOG, mMessagingPortMap, Sirikata::SpaceObjectReference::object(), and Sirikata::SpaceObjectReference::space().
v8::Handle< v8::Value > Sirikata::JS::EmersonScript::sendSandbox | ( | const String & | msgToSend, |
uint32 | senderID, | ||
uint32 | receiverID | ||
) |
msgToSend contains a serialized v8 object that will be sent from sandbox with id sendingSandbox to sandbox with id receivingSandbox.
Posts dow into processSandboxMessage, which actually dispatches the message in the correct context.
Returns undefined.
References EMERSCRIPT_SERIAL_CHECK, Sirikata::Liveness::livenessToken(), Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::objStrand, and processSandboxMessage().
void Sirikata::JS::EmersonScript::setBounds | ( | const SpaceObjectReference | sporef, |
const BoundingSphere3f & | bounds | ||
) |
void Sirikata::JS::EmersonScript::setLocation | ( | const SpaceObjectReference | sporef, |
const TimedMotionVector3f & | loc | ||
) |
void Sirikata::JS::EmersonScript::setOrientation | ( | const SpaceObjectReference | sporef, |
const TimedMotionQuaternion & | orient | ||
) |
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSObjectScript::mCtx, mParent, Sirikata::SpaceObjectReference::object(), and Sirikata::SpaceObjectReference::space().
Referenced by Sirikata::JS::JSPresenceStruct::setOrientationFunction(), and Sirikata::JS::JSPresenceStruct::setOrientationVelFunction().
void Sirikata::JS::EmersonScript::setPhysicsFunction | ( | const SpaceObjectReference | sporef, |
const String & | newPhysicsString | ||
) |
void Sirikata::JS::EmersonScript::setQueryFunction | ( | const SpaceObjectReference | sporef, |
const String & | query | ||
) |
void Sirikata::JS::EmersonScript::setVisual | ( | const SpaceObjectReference | sporef, |
const std::string & | newMeshString | ||
) |
void Sirikata::JS::EmersonScript::start | ( | ) | [virtual] |
Reimplemented from Sirikata::JS::JSObjectScript.
void Sirikata::JS::EmersonScript::stop | ( | ) | [virtual] |
Reimplemented from Sirikata::JS::JSObjectScript.
References iStop(), Sirikata::Liveness::livenessToken(), Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::objStrand, and Sirikata::JS::JSCtx::stop().
void Sirikata::JS::EmersonScript::unsubscribePresenceEvents | ( | const SpaceObjectReference & | name | ) | [private] |
References EMERSCRIPT_SERIAL_CHECK, jsVisMan, mParent, mPresences, Sirikata::SpaceObjectReference::object(), and Sirikata::SpaceObjectReference::space().
Referenced by iOnDisconnected(), and iStop().
bool Sirikata::JS::EmersonScript::valid | ( | ) | const |
Returns true if this script is valid, i.e.
if it was successfully loaded and initialized.
References mParent.
Referenced by Sirikata::JS::JSObjectScriptManager::createObjectScript().
v8::Local< v8::Object > Sirikata::JS::EmersonScript::wrapPresence | ( | JSPresenceStruct * | presToWrap, |
v8::Persistent< v8::Context > * | ctxToWrapIn | ||
) |
References EMERSCRIPT_SERIAL_CHECK, Sirikata::JS::JSContextStruct::mContext, Sirikata::JS::JSObjectScript::mContext, Sirikata::JS::JSObjectScript::mCtx, Sirikata::JS::JSCtx::mPresenceTemplate, PRESENCE_FIELD_PRESENCE, PRESENCE_TYPEID_STRING, and TYPEID_FIELD.
Referenced by Sirikata::JS::JSContextStruct::getAssociatedPresence(), handlePresCallback(), and restorePresence().
std::vector<JSContextStruct*> Sirikata::JS::EmersonScript::contextsToClear [private] |
Referenced by iHandleScriptCommRead(), and registerContextForClear().
Referenced by getEmersonHttpPtr().
bool Sirikata::JS::EmersonScript::mHandlingEvent [private] |
Referenced by iHandleScriptCommRead(), processSandboxMessage(), and registerContextForClear().
bool Sirikata::JS::EmersonScript::mKilling [private] |
Referenced by killEntity(), and postCallbackChecks().
Referenced by iOnConnected(), iStop(), removePresenceData(), and sendMessageToEntityUnreliable().
Referenced by create_entity(), create_event(), deletePres(), EmersonScript(), getHostedTime(), getQuery(), iOnConnected(), iStop(), mainStrandCompletePresConnect(), postDestroy(), requestDisconnect(), restorePresence(), runSimulation(), setBounds(), setLocation(), setOrientation(), setPhysicsFunction(), setQueryFunction(), setVisual(), unsubscribePresenceEvents(), and valid().
bool Sirikata::JS::EmersonScript::mResetting [private] |
Referenced by postCallbackChecks(), requestReset(), and resetScript().
Referenced by iStop(), and runSimulation().
Referenced by callbackUnconnected(), deletePres(), and restorePresence().
Referenced by incrementPresenceToken().
std::map<SpaceObjectReference,std::vector<JSVisibleStruct*> > Sirikata::JS::EmersonScript::resettingVisiblesResultSet [private] |
When we are resetting, we want to replay all the visibles that presences had received in their prox result set.
This map temporarily holds a list of these visibles (fills in requestReset, empties in resetScript). Index of map corresponds to presence whose prox set value is associated with.
Note: visibleManager class takes care of deleting memory allocated for JSVisibleStructs.
Referenced by requestReset(), and resetScript().