Checkpoint. Closing in on getting a chat client up, but slogging through

annoying streaming issues.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3984 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-28 01:27:57 +00:00
parent d910fbb6f2
commit 538803e1fb
15 changed files with 97 additions and 23 deletions
@@ -447,6 +447,7 @@ public class LocationDirector extends BasicDirector
// obtain our service handle
_lservice =
(client.requireService(LocationService) as LocationService);
Log.info("location service: " + _lservice);
}
protected function gotBodyObject (clobj :BodyObject) :void
@@ -21,6 +21,8 @@
package com.threerings.crowd.data {
import com.threerings.util.Integer;
import com.threerings.crowd.client.LocationService;
import com.threerings.crowd.client.MoveListener;
import com.threerings.crowd.data.PlaceConfig;
@@ -53,9 +55,10 @@ public class LocationMarshaller extends InvocationMarshaller
// documentation inherited from interface
public function moveTo (arg1 :Client, arg2 :int, arg3 :MoveListener) :void
{
com.threerings.crowd.Log.debug("issuing moveTo: " + _invCode);
var listener3 :MoveMarshaller = new MoveMarshaller();
listener3.listener = arg3;
sendRequest(arg1, MOVE_TO, [ arg2, listener3 ]);
sendRequest(arg1, MOVE_TO, [ new Integer(arg2), listener3 ]);
}
}
}
@@ -50,6 +50,9 @@ public class ObjectOutputStream
// TODO: if _nextCode blows short, log an error
writeShort(-cmap.code);
Log.debug("wrote classname: " +
((streamer == null) ? Translations.getToServer(cname)
: streamer.getJavaClassName()));
writeUTF((streamer == null) ? Translations.getToServer(cname)
: streamer.getJavaClassName());
@@ -30,6 +30,7 @@ public class ObjectArrayStreamer extends Streamer
:void
{
var arr :Array = (obj as Array);
com.threerings.presents.Log.debug("array length: " + arr.length);
out.writeInt(arr.length);
for (var ii :int = 0; ii < arr.length; ii++) {
out.writeObject(arr[ii]);
@@ -1,12 +1,12 @@
package com.threerings.msoy.client {
import flash.events.Event;
import mx.containers.HBox;
import mx.controls.Button;
import mx.controls.TextInput;
import mx.events.FlexEvent;
public class ChatControl extends HBox
{
public function ChatControl (ctx :MsoyContext)
@@ -18,11 +18,13 @@ public class ChatControl extends HBox
but.label = "Send"; // TODO: xlate
addChild(but);
_txt.addEventListener(FlexEvent.ENTER, sendChat);
but.addEventListener(FlexEvent.BUTTON_DOWN, sendChat);
//_txt.addEventListener(FlexEvent.ENTER, sendChat);
//but.addEventListener(FlexEvent.BUTTON_DOWN, sendChat);
_txt.addEventListener("enter", sendChat);
but.addEventListener("buttonDown", sendChat);
}
protected function sendChat (event :FlexEvent) :void
protected function sendChat (event :Event) :void
{
var message :String = _txt.text;
_txt.text = "";
@@ -1,9 +1,12 @@
package com.threerings.msoy.client {
import flash.events.Event;
import mx.controls.TextArea;
import com.threerings.crowd.chat.client.ChatDirector;
import com.threerings.crowd.chat.client.ChatDisplay;
import com.threerings.crowd.chat.data.ChatMessage;
public class ChatTextArea extends TextArea
implements ChatDisplay
@@ -36,7 +39,7 @@ public class ChatTextArea extends TextArea
* Check to see if we should register or unregister ourselves as a
* ChatDisplay.
*/
protected void checkVis (event :Event) :void
protected function checkVis (event :Event) :void
{
var chatdir :ChatDirector = _ctx.getChatDirector();
if (this.visible) {
@@ -1,11 +1,8 @@
package com.threerings.msoy.client {
import flash.util.describeType;
import mx.collections.ArrayCollection;
import flash.display.Stage;
import com.threerings.util.Name;
import com.threerings.presents.Log;
import com.threerings.presents.client.Client;
import com.threerings.presents.dobj.DSet;
import com.threerings.presents.data.ClientObject;
@@ -21,25 +18,50 @@ import com.threerings.crowd.data.BodyMarshaller;
import com.threerings.crowd.data.LocationMarshaller;
import com.threerings.crowd.chat.data.ChatMarshaller;
import com.threerings.msoy.Log;
import com.threerings.msoy.data.MsoyBootstrapData;
import com.threerings.msoy.data.SimpleChatConfig;
public class MsoyClient extends Client
{
public function MsoyClient ()
public function MsoyClient (stage :Stage)
{
super(new UsernamePasswordCreds(new Name("guest"), "guest"));
_ctx = new MsoyContext(this);
_ctx = new MsoyContext(this, stage);
setServer("tasman.sea.earth.threerings.net", DEFAULT_SERVER_PORT);
logon();
}
// // documetnation inherited
// public override function gotBootstrap (
// data :BootstrapData, omgr :DObjectManager) :void
// {
// super.gotBootstrap(data, omgr);
//
// // let's kick things off by going directly to our global chat room
// // TEMP
// _ctx.getLocationDirector().moveTo((data as MsoyBootstrapData).chatOid);
// }
// documetnation inherited
public override function gotClientObject (clobj :ClientObject) :void
{
super.gotClientObject(clobj);
_ctx.getLocationDirector().moveTo(
(getBootstrapData() as MsoyBootstrapData).chatOid);
}
public function fuckingCompiler () :void
{
var i :int = TimeBaseMarshaller.GET_TIME_OID;
i = LocationMarshaller.LEAVE_PLACE;
i = BodyMarshaller.SET_IDLE;
i = ChatMarshaller.AWAY;
var c :Class = SimpleChatConfig;
}
protected var _ctx :MsoyContext;
@@ -1,5 +1,8 @@
package com.threerings.msoy.client {
import flash.display.DisplayObject;
import flash.display.Stage;
import com.threerings.util.MessageManager;
import com.threerings.presents.client.Client;
@@ -16,9 +19,10 @@ import com.threerings.crowd.chat.client.ChatDirector;
public class MsoyContext
implements CrowdContext
{
public function MsoyContext (client :Client)
public function MsoyContext (client :Client, stage :Stage)
{
_client = client;
_stage = stage;
// TODO: verify params to these constructors
_msgmgr = new MessageManager("rsrc");
@@ -59,17 +63,23 @@ public class MsoyContext
// documentation inherited from interface CrowdContext
public function setPlaceView (view :PlaceView) :void
{
// TODO
for (var ii :int = _stage.numChildren - 1; ii >= 0; ii--) {
_stage.removeChildAt(ii);
}
_stage.addChild(view as DisplayObject);
}
// documentation inherited from interface CrowdContext
public function clearPlaceView (view :PlaceView) :void
{
// TODO
_stage.removeChild(view as DisplayObject);
}
protected var _client :Client;
protected var _stage :Stage;
protected var _msgmgr :MessageManager;
protected var _locdir :LocationDirector;
@@ -1,7 +1,8 @@
package com.threerings.msoy.client {
import com.threerings.crowd.client.CrowdContext;
import com.threerings.crowd.client.PlaceController;
import com.threerings.crowd.client.PlaceView;
import com.threerings.crowd.util.CrowdContext;
public class SimpleChatController extends PlaceController
{
@@ -2,6 +2,9 @@ package com.threerings.msoy.client {
import mx.containers.VBox;
import com.threerings.crowd.client.PlaceView;
import com.threerings.crowd.data.PlaceObject;
public class SimpleChatPanel extends VBox
implements PlaceView
{
@@ -0,0 +1,21 @@
package com.threerings.msoy.data {
import com.threerings.presents.net.BootstrapData;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
public class MsoyBootstrapData extends BootstrapData
{
/** The oid of the chat room we should join. */
public var chatOid :int;
// documentation inherited
public override function readObject (ins :ObjectInputStream) :void
{
super.readObject(ins);
chatOid = ins.readInt();
}
}
}
@@ -4,7 +4,7 @@ import com.threerings.crowd.data.PlaceConfig;
import com.threerings.msoy.client.SimpleChatController;
public class SimpleChatConfig implements PlaceConfig
public class SimpleChatConfig extends PlaceConfig
{
// documentation inherited
public override function getControllerClass () :Class
@@ -61,6 +61,9 @@ public class Communicator
Translations.addTranslation(
"com.threerings.presents.dobj.DSetEntry",
"com.threerings.presents.dobj.DSet$Entry");
Translations.addTranslation(
"com.threerings.crowd.data.MoveMarshaller",
"com.threerings.crowd.data.LocationMarshaller$MoveMarshaller");
}
public function logoff () :void
@@ -109,7 +109,7 @@ public class InvocationRequestEvent extends DEvent
super.writeObject(out);
out.writeInt(_invCode);
out.writeByte(_methodId);
out.writeObject(_args);
out.writeField(_args);
}
// documentation inherited from interface Streamable
@@ -118,7 +118,7 @@ public class InvocationRequestEvent extends DEvent
super.readObject(ins);
_invCode = ins.readInt();
_methodId = ins.readByte();
_args = (ins.readObject() as Array);
_args = (ins.readField(Array) as Array);
}
/** The code identifying which invocation provider to which this
@@ -45,7 +45,8 @@ public class InvocationResponseEvent extends DEvent
* only values of valid distributed object types.
*/
public function InvocationResponseEvent (
targetOid :int, requestId :int, methodId :int, args :Array)
targetOid :int = 0, requestId :int = 0, methodId :int = 0,
args :Array = null)
{
super(targetOid);
_requestId = requestId;
@@ -109,7 +110,7 @@ public class InvocationResponseEvent extends DEvent
super.writeObject(out);
out.writeShort(_requestId);
out.writeByte(_methodId);
out.writeObject(_args);
out.writeField(_args);
}
// documentation inherited
@@ -118,7 +119,7 @@ public class InvocationResponseEvent extends DEvent
super.readObject(ins);
_requestId = ins.readShort();
_methodId = ins.readByte();
_args = (ins.readObject() as Array);
_args = (ins.readField(Array) as Array);
}
/** The id of the request with which this response is associated. */