예제 #1
0
    protected NetCore()
    {
        seqid     = 0;
        encryptor = null;
        decryptor = null;

        connectDone = new ManualResetEvent(false);
        receiveDone = new ManualResetEvent(false);

        Byte[] _p = BitConverter.GetBytes(NetProto.Config.DH1PRIME);
        if (BitConverter.IsLittleEndian)
        {
            Array.Reverse(_p);
        }

        Byte[] _g = BitConverter.GetBytes(NetProto.Config.DH1BASE);
        if (BitConverter.IsLittleEndian)
        {
            Array.Reverse(_g);
        }

        enc_dh = new DiffieHellmanManaged(_p, _g, 31);
        dec_dh = new DiffieHellmanManaged(_p, _g, 31);

        msg_queue  = new Queue();
        Handle     = new NetProto.NetHandle();
        dispatcher = new NetProto.Dispatcher();
    }
예제 #2
0
    protected NetCore()
    {
        seqId     = 0;
        encryptor = null;
        decryptor = null;

        Byte[] _p = BitConverter.GetBytes(NetProto.Config.DH1PRIME);
        if (BitConverter.IsLittleEndian)
        {
            Array.Reverse(_p);
        }

        Byte[] _g = BitConverter.GetBytes(NetProto.Config.DH1BASE);
        if (BitConverter.IsLittleEndian)
        {
            Array.Reverse(_g);
        }

        dhEnc = new DiffieHellmanManaged(_p, _g, 31);
        dhDec = new DiffieHellmanManaged(_p, _g, 31);

        msgQueue   = new Queue();
        Handle     = new NetProto.NetHandle();
        dispatcher = new NetProto.Dispatcher();
        // 注册回调
        dispatcher.Register(Handle);
    }
예제 #3
0
파일: Dispatcher.cs 프로젝트: en/libunity
 public void Register(NetHandle handle)
 {
     foreach(var v in handle.handlerMap)
     {
         RegisterHandler(v.Key, v.Value);
     }
 }