Esempio n. 1
0
        public byte[] pack(ProtocolObject obj)
        {
            byte[] outBuffer = packObject(obj);
            MemoryStream memStream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(memStream);

            writer.Write(System.Net.IPAddress.HostToNetworkOrder(outBuffer.Length + 5));
            writer.Write(obj.classId());
            writer.Write(outBuffer);
            byte[] outBuf = new byte[memStream.Length];
            memStream.Position = 0;
            memStream.Read(outBuf, 0, (int)memStream.Length);
            return outBuf;
        }
Esempio n. 2
0
        public byte[] pack(ProtocolObject obj)
        {
            byte[]       outBuffer = packObject(obj);
            MemoryStream memStream = new MemoryStream();
            BinaryWriter writer    = new BinaryWriter(memStream);

            writer.Write(System.Net.IPAddress.HostToNetworkOrder(outBuffer.Length + 5));
            writer.Write(obj.classId());
            writer.Write(outBuffer);
            byte[] outBuf = new byte[memStream.Length];
            memStream.Position = 0;
            memStream.Read(outBuf, 0, (int)memStream.Length);
            return(outBuf);
        }
Esempio n. 3
0
    /// <summary>
    /// Process all packet from cubeia server.
    /// </summary>
    /// <param name="protocolObject">Protocol object.</param>

    public void handlePacket(ProtocolObject protocolObject)
    {
        Debug.Log("<--------- receive: " + protocolObject.ToString());

        switch (protocolObject.classId())
        {
        case LoginResponsePacket.CLASSID:
            handleLoginResponsePacket((LoginResponsePacket)protocolObject);
            break;

        case TableSnapshotListPacket.CLASSID:
            handleTableSnapshotListPacket((TableSnapshotListPacket)protocolObject);
            break;

        case ServiceTransportPacket.CLASSID:
            ServiceTransportPacketProcessor.handleServiceTransportPacket((ServiceTransportPacket)protocolObject);
            break;

        case GameTransportPacket.CLASSID:
            gameController.handleBallsUpdate((GameTransportPacket)protocolObject);
//				GameTransportPacketProcessor.handleGameTransportPacket((GameTransportPacket)protocolObject);
            break;

        case JoinResponsePacket.CLASSID:
            handleJoinResponsePacket((JoinResponsePacket)protocolObject);
            break;

        case LeaveResponsePacket.CLASSID:
            handleLeaveResponsePacket((LeaveResponsePacket)protocolObject);
            break;

        case PingPacket.CLASSID:
            handlePingPacket((PingPacket)protocolObject);
            break;
        }
    }