Example #1
0
    public void ClientSend(ArraySegment <byte> data, int channel)
    {
#if MIRROR_40_0_OR_NEWER
        directConnectTransport.ClientSend(data, channel);
#else
        directConnectTransport.ClientSend(channel, data);
#endif
    }
 void SendHeartbeat()
 {
     if (_connectedToRelay)
     {
         int pos = 0;
         _clientSendBuffer.WriteByte(ref pos, 200);
         clientToServerTransport.ClientSend(0, new ArraySegment <byte>(_clientSendBuffer, 0, pos));
     }
 }
Example #3
0
File: Monke.cs Project: dededec/TFG
    private void OnClientDataReceive(ArraySegment <byte> data, int channel)
    {
        try
        {
            var rawData = data.Array;
            int pos     = data.Offset;

            OpCodes opcode = (OpCodes)rawData.ReadByte(ref pos);

            switch (opcode)
            {
            case OpCodes.ServerPublicKey:
                _serverPublicKey = rawData.ReadBytes(ref pos);

                pos = 0;
                _clientSendBuffer.WriteByte(ref pos, (byte)OpCodes.ClientPublicKey);
                _clientSendBuffer.WriteBytes(ref pos, _keyPair.PublicKey);
                CommunicationTransport.ClientSend(Channels.Reliable, new ArraySegment <byte>(_clientSendBuffer, 0, pos));

                if (showDebugLogs)
                {
                    Debug.Log($"<color=green>MONKE | CLIENT RECIEVED SERVER PUBLIC KEY!</color>");
                }

                OnClientConnected?.Invoke();

                break;

            case OpCodes.Data:
                _readBuffer = rawData.ReadBytes(ref pos);
                _nonce      = rawData.ReadBytes(ref pos);

                _encryptionBuffer = PublicKeyBox.Open(_readBuffer, _nonce, _keyPair.PrivateKey, _serverPublicKey);
                OnClientDataReceived?.Invoke(new ArraySegment <byte>(_encryptionBuffer), channel);


                if (showDebugLogs)
                {
                    Debug.Log($"<color=green>MONKE | CLIENT DATA | RAW DATA: " + _readBuffer.Length + " DECRYPTED DATA LENGTH: " + _encryptionBuffer.Length + "</color>" +
                              " <color=yellow>DELTA: " + (_readBuffer.Length - _encryptionBuffer.Length) + "</color>");
                }

                break;
            }
        }
        catch (Exception e)
        {
            Debug.LogError("Error: " + e);
        }
    }
Example #4
0
 public void ClientSendPacket(DeliveryMethod deliveryMethod, ushort msgType, System.Action <NetDataWriter> serializer)
 {
     writer.Reset();
     writer.PutPackedUShort(msgType);
     if (serializer != null)
     {
         serializer.Invoke(writer);
     }
     Transport.ClientSend(deliveryMethod, writer);
 }
Example #5
0
 public void ClientSendPacket(SendOptions options, ushort msgType, System.Action <NetDataWriter> serializer)
 {
     writer.Reset();
     writer.PutPackedUShort(msgType);
     if (serializer != null)
     {
         serializer.Invoke(writer);
     }
     Transport.ClientSend(options, writer);
 }
Example #6
0
 public void SendResponse <T>(ushort msgType, T messageData, Action <NetDataWriter> extraSerializer = null) where T : BaseAckMessage
 {
     writer.Reset();
     writer.PutPackedUShort(msgType);
     messageData.Serialize(writer);
     if (extraSerializer != null)
     {
         extraSerializer.Invoke(writer);
     }
     Transport.ClientSend(DeliveryMethod.ReliableOrdered, writer);
 }
Example #7
0
 protected override void SendMessage(long connectionId, DeliveryMethod deliveryMethod, NetDataWriter writer)
 {
     Transport.ClientSend(deliveryMethod, writer);
 }
Example #8
0
 public void ClientSend(ArraySegment <byte> data, int channel)
 {
     directConnectTransport.ClientSend(channel, data);
 }
 public bool ClientSend(ArraySegment <byte> data, int channel)
 {
     return(directConnectTransport.ClientSend(channel, data));
 }
Example #10
0
 public override void SendMessage(long connectionId, byte dataChannel, DeliveryMethod deliveryMethod, NetDataWriter writer)
 {
     Transport.ClientSend(dataChannel, deliveryMethod, writer);
 }
Example #11
0
 public override void ClientSend(int channelId, ArraySegment <byte> segment)
 {
     available.ClientSend(channelId, segment);
 }