Package megamek.common.net.marshall

Examples of megamek.common.net.marshall.PacketMarshaller


     * Sets the type of the marshalling used to send packets
     *
     * @param marshallingType new marhalling type
     */
    protected void setMarshallingType(int marshallingType) {
        PacketMarshaller pm = marshallerFactory.getMarshaller(marshallingType);
        megamek.debug.Assert.assertTrue(pm != null, "Unknown marshalling type");
        this.marshallingType = marshallingType;
        marshaller = pm;
    }
View Full Code Here


    /**
     * process a received packet
     */
    protected void processPacket(INetworkPacket np) throws Exception {
        PacketMarshaller pm = marshallerFactory.getMarshaller(np
                .getMarshallingType());
        megamek.debug.Assert.assertTrue(pm != null, "Unknown marshalling type");
        Packet packet = null;
        byte[] data = np.getData();
        bytesReceived += data.length;
        ByteArrayInputStream bis = new ByteArrayInputStream(data);
        InputStream in;
        if (np.isCompressed()) {
            in = new GZIPInputStream(bis);
        } else {
            in = bis;
        }
        // TBD this is stupid. pm should be always non null right?
        if (pm != null) {
            packet = pm.unmarshall(in);
            if (packet != null) {
                debugLastFewCommandsReceived.push(packet.getCommand());
                processConnectionEvent(new PacketReceivedEvent(
                        AbstractConnection.this, packet));
            }
View Full Code Here

TOP

Related Classes of megamek.common.net.marshall.PacketMarshaller

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.