/// <summary> /// /// </summary> /// <param name="packet"></param> /// <param name="packetCode"></param> /// <param name="deliveryMethod"></param> /// <param name="encrypt"></param> /// <param name="channel"></param> /// <exception cref="LoggableException">Throws a loggable exception generally when packet serialization fails. You should catch this.</exception> /// <returns></returns> public Packet.SendResult SendResponse(PacketBase packet, byte packetCode, Packet.DeliveryMethod deliveryMethod, int channel = 0, byte encrypt = EncryptionBase.NoEncryptionByte) { try { return(this.SendMessage(Packet.OperationType.Response, packet, packetCode, deliveryMethod, channel, encrypt)); } catch (LoggableException e) { throw; } }
/// <summary> /// /// </summary> /// <param name="packet"></param> /// <param name="packetCode"></param> /// <param name="deliveryMethod"></param> /// <param name="encrypt"></param> /// <param name="channel"></param> /// <exception cref="LoggableException">Throws a loggable exception generally when packet serialization fails. You should catch this.</exception> /// <returns></returns> public Packet.SendResult SendResponse(PacketBase packet, byte packetCode, Packet.DeliveryMethod deliveryMethod, int channel = 0, bool encrypt = false) { try { return(SendResponse(packet, packetCode, deliveryMethod, channel, encrypt ? EncryptionBase.DefaultByte : EncryptionBase.NoEncryptionByte)); } catch (LoggableException e) { throw; } }
public Packet.SendResult SendRequest(PacketBase packet, byte packetCode, Packet.DeliveryMethod deliveryMethod, int channel, byte encrypt) { try { return(this.SendMessage(Packet.OperationType.Request, packet, packetCode, deliveryMethod, channel, encrypt)); } catch (LoggableException e) { QueueStatusChange(StatusChange.NetworkSendError); throw; } }
public Packet.SendResult SendRequest(PacketBase packet, byte packetCode, Packet.DeliveryMethod deliveryMethod, int channel = 0, bool encrypt = false) { return(this.SendRequest(packet, packetCode, deliveryMethod, channel, encrypt ? (byte)1 : (byte)0)); }
public Packet.SendResult SendEvent(PacketBase packet, byte packetCode, Packet.DeliveryMethod deliveryMethod, int channel = 0, bool encrypt = false) { return(this.SendEvent(packet, packetCode, deliveryMethod, channel, encrypt ? EncryptionBase.DefaultByte : EncryptionBase.NoEncryptionByte)); }
//This does not need to be in a unity peer. A Unity peer cannot broadcast. #if !UNITYDEBUG && !UNITYRELEASE //TODO: One day we will need to optimize the ability to broadcast messages as we'll have to convert to a NetConnection list at some point when it's being called externally through //the exposed API of GladNet. protected void BroadcastEvent(IList <Peer> connections, PacketBase packet, byte packetCode, Packet.DeliveryMethod deliveryMethod, byte encrypt = EncryptionBase.NoEncryptionByte, int channel = 0) { try { LidgrenTransferPacket transferPacket = new LidgrenTransferPacket(Packet.OperationType.Event, 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); //Inefficient O(n) casting to a NetConnection list. Not good. this.InternalNetConnection.Peer.SendMessage(false, connections.Select(x => x.InternalNetConnection).ToList(), bytes, Packet.LidgrenDeliveryMethodConvert(deliveryMethod), channel); } catch (LoggableException e) { throw; } catch (Exception e) { throw new LoggableException("Exception occured in serialization of packet.", e, LogType.Error); } }
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); } }
//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)