コード例 #1
0
 protected override UdpSendStatus SendRawMessage(Networking.Udp.Messages.MessageInfo messageInfo)
 {
     using (messageInfo.Message)
     {
         UdpRawMessage encryptedMessage = messageInfo.Message.Encrypt(cipher);
         return(base.SendRawMessage(new Networking.Udp.Messages.MessageInfo(encryptedMessage, messageInfo.DeliveryType,
                                                                            messageInfo.Channel)));
     }
 }
コード例 #2
0
        protected override void OnMessageReceived(Networking.Udp.Messages.MessageInfo messageInfo)
        {
            try
            {
                if (dh.Status == DiffieHellmanImpl.DhStatus.None)
                {
                    logger.Debug($"Got secure handshake request");
                    var responseMessage = Parent.CreateMessage();
                    dh.RecvHandshakeRequest(messageInfo.Message.BaseStream, responseMessage.BaseStream);
                    _ = SendMessage(new Networking.Udp.Messages.MessageInfo(responseMessage, DeliveryType.ReliableOrdered, 0));
                    logger.Debug($"Sent secure handshake response, common key set!");
                    base.InitSession();
                    return;
                }

                if (dh.Status == DiffieHellmanImpl.DhStatus.WaitingForServerMod)
                {
                    dh.RecvHandshakeResponse(messageInfo.Message.BaseStream);
                    logger.Debug($"Got secure handshake response, common key set!");
                    base.InitSession();
                    return;
                }
            }
            catch (Exception e)
            {
                logger.Error($"Handshake failed for {this}. Closing... {e}");
                Close();
                return;
            }

            try
            {
                using (messageInfo.Message)
                {
                    using (var decryptedMessage = messageInfo.Message.Decrypt(cipher))
                    {
                        base.OnMessageReceived(new Networking.Udp.Messages.MessageInfo(decryptedMessage, messageInfo.DeliveryType, messageInfo.Channel));
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error($"Unhandled exception in {nameof(RpcTcpConnectionEncrypted)}.{nameof(OnMessageReceived)}: {e}");
                Close();
            }
        }
コード例 #3
0
 protected override void OnMessageReceived(Networking.Udp.Messages.MessageInfo messageInfo)
 {
     try
     {
         using (messageInfo.Message)
         {
             using (WardenStreamReader sr = new WardenStreamReader(messageInfo.Message.BaseStream, true))
             {
                 session.OnMessage(sr);
             }
         }
     }
     catch (Exception e)
     {
         logger.Error($"Unhandled exception in {nameof(RpcUdpConnection)}.{nameof(OnMessageReceived)}: {e}");
         Close();
     }
 }