Use the game engine photon to create a special remote control software

Source: Internet
Author: User

Objective

This article mainly introduces some basic usage of photon engine and the advantage of using game engine to develop remote control.

0x1

Some time on the unity of the game to develop a bit of interest in the game to find the engine of the server, suddenly found the photon developed the game engine, the engine is very little information, a great effort to learn some basic knowledge.

For C # yards, this engine is really powerful, very labor-saving, and very good with C #. The downside is that it's a commercial engine, but the cock wire is a key that can apply for 100 connections free of charge. Features such as a pallet console and log viewing are provided.

0x2

All right, nonsense, let's get to the point. The photon engine loads the DLLs that you have developed in a way that loads modules. For example, the logic of the game compiled into Dll,phototn responsible for the network connection and other complex operations.

and help you complete IOCP and remote function calls . That's the point. Those complex multi-threaded network operations will be done by photon.

There are 2 main types of our traditional Trojans.

The first is the most primitive, the Trojan itself listens to a port, waiting for connections and instructions

The second kind is similar to the gray pigeon rebound connection, the Trojan horse through the domain name, the IP initiative to connect the broiler owner.

Then, the problem comes, both of these methods are very easy to be safe to explode chrysanthemum, because through the IP can directly identify the source, to find the control side.

So I was wondering if it was possible to develop a remote control through the game engine, so that both the controller and the controller are equal to the game participants, the accused is a regular player, the controller is equivalent to the game GM, the server will send the instructions to the broiler through the broadcast, so that the network protocol can not confirm who the controller is.

------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------

0x3

Because photon is running the DLL module that loads C #, we just need to develop a DLL for our use, instead of having to change the engine itself.

First, create a class, inherit ApplicationBase, return a subclass of peerbase in the Createpeer function, of course, this subclass is developed by itself. My name is Fuckpeer. The rest of the code is log settings, so that you can see your log in photon control, easy to debug

Specific Peer Development website demo is very detailed, please download it directly. After compiling the DLL, you also need to modify the configuration file of the photon server photonserver.config

Please note that Nbdoor is the DLL I wrote, I have the official website of the demo are deleted, otherwise the startup speed is very slow.

1 <?XML version= "1.0" encoding= "Windows-1252"?>2 <!--3 (c) by Exit Games GmbH, http://www.exitgames.com4 Photon Server configuration file.5 For details see the photon-config.pdf.6 7 This file contains the configurations:8 9 "Default"Ten Default. Various applications and demos. One starts the Apps:lite, Litelobby, Mmodemo, Counterpublisher and Policy A Listens:udp-port 5055, tcp-port:4530, 843 and 943 - "Loadbalancing" - loadbalanced setup for local development:a master-server and both game-servers. the starts the apps:game1, Game2, Master, Counterpublisher and Policy - Listens:udp-port 5055, tcp-port:4530, 843 and 943 -  - -  + <Configuration> -     <!--multiple instances is supported. Each instance have its own node in the config file.  - +     <!--Photoncontrol would currently only start "Default" but the. cmd files could is modified to start other instances.  - A  at     <!--Instance Settings - -     <Default -         maxmessagesize= "512000" - Maxqueueddataperpeer= "512000" - Perpeermaxreliabledataintransit= "51200" - perpeertransmitratelimitkbsec= " the" in Perpeertransmitrateperiodmilliseconds= "$" - Minimumtimeout= "+" to Maximumtimeout= "$"> +          -         <!--0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define, the correct one here.  - the         <!--Port 5055 is Photon ' s default for UDP connections. - *         <udplisteners> $             <UdplistenerPanax Notoginseng                 IPAddress= "0.0.0.0" - Port= "5055"> the             </Udplistener> +         </udplisteners> A      the         <!--0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define, the correct one here.  - +         <!--Port 4530 is Photon ' s default for TCP connecttions. - -         <!--A policy application is defined in case that Policy requests be sent to this listener (known bug of some some flash Clients) -  $         <tcplisteners> $             <TcpListener -                 IPAddress= "0.0.0.0" - Port= "4530" the PolicyFile= "Policy\assets\socket-policy.xml" - InactivityTimeout= "10000"Wuyi                 > the             </TcpListener> -         </tcplisteners> Wu  -       About  $       -  -         <!--defines the Photon Runtime Assembly to use. - -         <Runtime A             Assembly= "Photonhostruntime, culture=neutral" + Type= "Photonhostruntime.photondomainmanager" the Unhandledexceptionpolicy= "Ignore"> -         </Runtime> $                  the  the         <!--defines which applications was loaded on start and which of them was used by default. Make sure the default application is defined.  - the         <!--Application-folders must is located in the same folder as the Bin_win32 folders. The basedirectory must include a "bin" folder.  - the         <ApplicationsDefault= "Nbdoor"> -   in  the       the          About         <Application the         Name= "Nbdoor" the basedirectory= "Nbdoor" the Assembly= "Nbdoor" + Type= "Nbdoor.nbserverapplication" - Enableautorestart= "true" the Watchfiles= "Dll;config"Bayi Excludefiles= "Log4net.config"> the         </Application> the              -              -              the              the         </Applications> the          the          -     </Default> the  the     <loadbalancing the         maxmessagesize= "512000"94 Maxqueueddataperpeer= "512000" the Perpeermaxreliabledataintransit= "51200" the perpeertransmitratelimitkbsec= " the" the Perpeertransmitrateperiodmilliseconds= "$"98 Minimumtimeout= "the" About Maximumtimeout= "30000" - DisplayName= "loadbalancing (mycloud)">101 102      103         104   the          106 107         <!--defines the Photon Runtime Assembly to use. -108         <Runtime109             Assembly= "Photonhostruntime, culture=neutral" the Type= "Photonhostruntime.photondomainmanager"111 Unhandledexceptionpolicy= "Ignore"> the         </Runtime>113  the           the     </loadbalancing> the </Configuration>

0x4

Control End and Trojan horse program. The control side should actually be similar to the Trojan horse program function. Just the interface is different.

Both are directly connected to the game engine server, then send instructions, wait for the remote function callback, and so on.

Through peer. Connect can connect directly to the server and need to indicate the module name, which is the same as the module name on the server

    Public void Conn ()        {            if (peer. Connect ("127.0.0.1:5055" "nbdoor"))            {                th. Start ();            }        }

GM administrators and ordinary users are different, GM can send a password, the game server to determine their own administrator identity, so that the server will be the current connection to identify, so that can call the administrator's method, The server then passes the Peerbase.sendevent function, sends the event to the broiler, executes the instruction

Test effect

Use the game engine photon to create a special remote control software

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.