//
// $Id: ObjectResponse.java,v 1.2 2001/05/23 04:03:40 mdb Exp $

package com.samskivert.cocktail.cher.net;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.DataOutputStream;

import com.samskivert.cocktail.cher.dobj.DObject;
import com.samskivert.cocktail.cher.io.TypedObjectFactory;

public class ObjectResponse extends DownstreamMessage
{
    /** The code for an event notification. */
    public static final short TYPE = TYPE_BASE + 2;

    /**
     * Zero argument constructor used when unserializing an instance.
     */
    public ObjectResponse ()
    {
        super();
    }

    /**
     * Constructs an object response with supplied distributed object that
     * is associated with the specified upstream message id.
     */
    public ObjectResponse (short messageId, DObject dobj)
    {
        this.messageId = messageId;
        _dobj = dobj;
    }

    public short getType ()
    {
        return TYPE;
    }

    public void writeTo (DataOutputStream out)
        throws IOException
    {
        super.writeTo(out);
        out.writeShort(messageId);
        TypedObjectFactory.writeTo(out, _dobj);
    }

    public void readFrom (DataInputStream in)
        throws IOException
    {
        super.readFrom(in);
        messageId = in.readShort();
        _dobj = (DObject)TypedObjectFactory.readFrom(in);
    }

    /** The object which is associated with this response. */
    protected DObject _dobj;
}

//
// $Id: ObjectResponse.java,v 1.3 2001/05/29 03:28:50 mdb Exp $

package com.samskivert.cocktail.cher.net;

import java.io.IOException;
import java.io.DataInputStream;
import java.io.DataOutputStream;

import com.samskivert.cocktail.cher.dobj.DObject;
import com.samskivert.cocktail.cher.dobj.DObjectFactory;

public class ObjectResponse extends DownstreamMessage
{
    /** The code for an event notification. */
    public static final short TYPE = TYPE_BASE + 2;

    /**
     * Zero argument constructor used when unserializing an instance.
     */
    public ObjectResponse ()
    {
        super();
    }

    /**
     * Constructs an object response with supplied distributed object that
     * is associated with the specified upstream message id.
     */
    public ObjectResponse (short messageId, DObject dobj)
    {
        this.messageId = messageId;
        _dobj = dobj;
    }

    public short getType ()
    {
        return TYPE;
    }

    public void writeTo (DataOutputStream out)
        throws IOException
    {
        super.writeTo(out);
        out.writeShort(messageId);
        DObjectFactory.writeTo(out, _dobj);
    }

    public void readFrom (DataInputStream in)
        throws IOException
    {
        super.readFrom(in);
        messageId = in.readShort();
        _dobj = (DObject)DObjectFactory.readFrom(in);
    }

    /** The object which is associated with this response. */
    protected DObject _dobj;
}

Use the DObjectFactory to move DObjects over the wire.
Use the DObjectFactory to move DObjects over the wire.


git-svn-id: a1a4b28b82a3276cc491891159dd9963a0a72fae@7 542714f4-19e9-0310-aa3c-eee0fc999fb1
