zoukankan      html  css  js  c++  java
  • indy 封包转发

    type
      TMySuperMappedPortContext
    = Class(TIdMappedPortContext)
        public
         
    procedure DoEncode;
         
    procedure DoDecode;
      End;


    implementation

    {自定义加密函数}
    function EncodeData(Src: String): String;
    begin
      Result :
    = Src;
    end;

    {自定义解密函数}
    function DecodeData(Src: String): String;
    begin
      Result :
    = Src;
    end;


    {自定义加密接口}
    procedure TMySuperMappedPortContext.DoEncode;
    begin
      FNetData :
    = EncodeData(FNetData);
    end;

    {自定义解密接口}
    procedure TMySuperMappedPortContext.DoDecode;
    begin
      FNetData :
    = DecodeData(FNetData);
    end;

    {OnBeforeListenerRun事件}
    {替换相应的映射消息处理类型}
    procedure TForm1.IdMappedPortTCP1BeforeListenerRun(AThread: TIdThread);
    begin
      IdMappedPortTCP1.ContextClass :
    = TMySuperMappedPortContext;
    end;

    {OnExecute事件}
    {接收到须转发的数据,调用DoEncode进行"加密"}
    procedure TForm1.IdMappedPortTCP1Execute(AContext: TIdContext);
    begin
     
    if AContext is TMySuperMappedPortContext then begin
        TMySuperMappedPortContext(AContext).DoEncode;
     
    end;
    end;

    {OnOutboundData事件}
    {接收到须转发的数据,调用DoDecode进行"解密"}
    procedure TForm1.IdMappedPortTCP1OutboundData(AContext: TIdContext);
    begin
     
    if AContext is TMySuperMappedPortContext then begin
        TMySuperMappedPortContext(AContext).DoDecode;
     
    end;
    end;
  • 相关阅读:
    构造 非构造 代码块
    Random 类生成随机数
    JAVA寄存器
    PyCharm配置远程python解释器和在本地修改服务器代码
    Java实现常见的排序算法
    推荐系统冷启动问题解决方案
    AVL树C代码
    AVL树->图解2
    AVL树->图解1
    二叉查找树(Binary Sort Tree)
  • 原文地址:https://www.cnblogs.com/jxgxy/p/1401506.html
Copyright © 2011-2022 走看看