示例#1
0
        public virtual Packet.SendResult SendMessage(Packet.OperationType type, PacketBase packet, byte packetCode, Packet.DeliveryMethod deliveryMethod, int channel = 0, byte encrypt = EncryptionBase.NoEncryptionByte, bool isInternal = false)
#endif
        {
            try
            {
                LidgrenTransferPacket transferPacket = new LidgrenTransferPacket(type, packet.SerializerKey, packetCode, packet.Serialize());

                if (encrypt != EncryptionBase.NoEncryptionByte)
                {
                    EncryptionLidgrenPackage(encrypt, transferPacket);
                }

                //TODO: encryption because it's ready
                byte[] bytes = Serializer <GladNetProtobufNetSerializer> .Instance.Serialize(transferPacket);

                return((Packet.SendResult) this.InternalNetConnection.SendMessage(isInternal, bytes, Packet.LidgrenDeliveryMethodConvert(deliveryMethod), channel));
            }
            catch (LoggableException e)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new LoggableException("Exception occured in serialization of packet.", e, LogType.Error);
            }
        }
示例#2
0
        public LidgrenTransferPacket(Packet.OperationType opType, byte serializationKey, byte packetCode, byte[] messageContents)
        {
            //If someone chooses not to pass a packet then we'll use the empty packet.
            if (messageContents != null)
            {
                InternalByteRepresentation = messageContents;
                SerializerKey = serializationKey;
            }
            else
            {
                messageContents = Serializer <GladNetProtobufNetSerializer> .Instance.Serialize(Packet.Empty);

                serializationKey = Serializer <GladNetProtobufNetSerializer> .Instance.SerializerUniqueKey;
            }

            OperationType = opType;
            PacketCode    = packetCode;

            EncryptionMethodByte = EncryptionBase.NoEncryptionByte;
            decrypted            = false;
        }
示例#3
0
        //Unity really hates Internal. Unity I hate you.
        //TODO: Implementation encryption functionality
#if !UNITYDEBUG && !UNITYRELEASE
        internal virtual Packet.SendResult SendMessage(Packet.OperationType type, PacketBase packet, byte packetCode, Packet.DeliveryMethod deliveryMethod, int channel = 0, byte encrypt = EncryptionBase.NoEncryptionByte, bool isInternal = false)