diff --git a/src/as/com/threerings/crowd/data/ManagerCaller.as b/src/as/com/threerings/crowd/data/ManagerCaller.as index 2d0985fc2..f87a65359 100644 --- a/src/as/com/threerings/crowd/data/ManagerCaller.as +++ b/src/as/com/threerings/crowd/data/ManagerCaller.as @@ -21,6 +21,8 @@ package com.threerings.crowd.data { +import com.threerings.presents.dobj.ServerMessageEvent; + public class ManagerCaller { public function ManagerCaller (plobj :PlaceObject) @@ -33,7 +35,7 @@ public class ManagerCaller */ public function invoke (method :String, ... args) :void { - _plobj.postMessage(method, args); + _plobj.postEvent(new ServerMessageEvent(_plobj.getOid(), method, args)); } /** The place object we're thingy-ing for. */ diff --git a/src/as/com/threerings/presents/dobj/ServerMessageEvent.as b/src/as/com/threerings/presents/dobj/ServerMessageEvent.as new file mode 100644 index 000000000..33b5eea1d --- /dev/null +++ b/src/as/com/threerings/presents/dobj/ServerMessageEvent.as @@ -0,0 +1,56 @@ +// +// $Id$ +// +// Narya library - tools for developing networked games +// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved +// http://www.threerings.net/code/narya/ +// +// This library is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package com.threerings.presents.dobj { + +/** + * A message event that only goes to the server. If generated on the server then it never leaves + * the server. + */ +public class ServerMessageEvent extends MessageEvent +{ + /** + * Constructs a new message event on the specified target object with + * the supplied name and arguments. + * + * @param targetOid the object id of the object whose attribute has + * changed. + * @param name the name of the message event. + * @param args the arguments for this message. This array should + * contain only values of valid distributed object types. + */ + public function ServerMessageEvent ( + targetOid :int = 0, name :String = null, args :Array = null) + { + super(targetOid, name, args); + } + +// Note: isPrivate() is currently not implemented in actionscript, since +// it's a server-only attribute. Rest assured that this event will still +// only be server-only, as it will unserialize into a Java ServerMessageEvent +// on the server and then be properly private. +// override public function isPrivate () :Boolean +// { +// // this is what makes us server-only +// return true; +// } +} +} diff --git a/src/java/com/threerings/crowd/data/PlaceObject.java b/src/java/com/threerings/crowd/data/PlaceObject.java index 9f36c4f1f..47d9d165f 100644 --- a/src/java/com/threerings/crowd/data/PlaceObject.java +++ b/src/java/com/threerings/crowd/data/PlaceObject.java @@ -28,6 +28,7 @@ import com.threerings.util.Name; import com.threerings.presents.dobj.DObject; import com.threerings.presents.dobj.DSet; import com.threerings.presents.dobj.OidList; +import com.threerings.presents.dobj.ServerMessageEvent; import com.threerings.crowd.Log; import com.threerings.crowd.chat.data.SpeakMarshaller; @@ -60,7 +61,7 @@ public class PlaceObject extends DObject public class ManagerCaller { public void invoke (String method, Object ... args) { - postMessage(method, args); + postEvent(new ServerMessageEvent(_oid, method, args)); } } diff --git a/src/java/com/threerings/presents/dobj/ServerMessageEvent.java b/src/java/com/threerings/presents/dobj/ServerMessageEvent.java new file mode 100644 index 000000000..ee18cd5e2 --- /dev/null +++ b/src/java/com/threerings/presents/dobj/ServerMessageEvent.java @@ -0,0 +1,60 @@ +// +// $Id$ +// +// Narya library - tools for developing networked games +// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved +// http://www.threerings.net/code/narya/ +// +// This library is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published +// by the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package com.threerings.presents.dobj; + +import com.samskivert.util.StringUtil; + +/** + * A message event that only goes to the server. If generated on the server then it never leaves + * the server. + */ +public class ServerMessageEvent extends MessageEvent +{ + /** + * Constructs a new message event on the specified target object with + * the supplied name and arguments. + * + * @param targetOid the object id of the object whose attribute has + * changed. + * @param name the name of the message event. + * @param args the arguments for this message. This array should + * contain only values of valid distributed object types. + */ + public ServerMessageEvent (int targetOid, String name, Object[] args) + { + super(targetOid, name, args); + } + + /** + * Suitable for unserialization. + */ + public ServerMessageEvent () + { + } + + @Override + public boolean isPrivate () + { + // this is what makes us server-only + return true; + } +}