コード例 #1
0
        public INetwork CreateRemoteNetwork(IPEndPoint ip, int encryptionKey)
        {
            int packetId = new Random().Next(20000, 40000);

            var session = new RemoteNetwork(new WorldEncoder(encryptionKey), new WorldDecoder(), 0xFF)
            {
                Modifiers = new Func <string, string>[]
                {
                    x => $"{packetId++} {x}"
                }
            };

            int keepAliveId = 0;
            var keepAlive   = new Timer
            {
                Interval = 60000,
                Enabled  = true
            };

            keepAlive.Elapsed += (obj, e) =>
            {
                if (!session.Client.Connected)
                {
                    keepAlive.Stop();
                }

                session.SendPacket($"pulse {keepAliveId++ * 60} 1");
            };

            session.Connect(ip);

            return(session);
        }
コード例 #2
0
        public INetwork CreateRemoteNetwork(IPEndPoint ip)
        {
            var network = new RemoteNetwork(new LoginEncoder(), new LoginDecoder(), 25);

            network.Connect(ip);

            return(network);
        }