• 主页

  • 投资

  • IT

    🔥
  • 设计

  • 销售

  • 共151篇

    Unity - 游戏引擎

关闭

返回栏目

关闭

返回Unity - 游戏引擎栏目

52 - 配置 - Photon2 Server 服务器 applications管理器

作者:

贺及楼

成为作者

更新日期:2023-09-17 10:48:49

作用:配置Photon2 Server

只能使用windows server 服务器

文件目录

  1. C:.
  2. app.config------------------------------#配置文件-不用怎么改
  3. ClientPeer.cs---------------------------#客户端文件
  4. hibernate.cfg.xml----------------------#连接数据库配置文件
  5. log4net.config---------------------------#日志配置文件
  6. MyGameServer.cs-----------------------#
  7. MyGameServer.csproj------------------#
  8. NHibernateHelper.cs-------------------#连接数据库帮助文件
  9. packages.config-------------------------#
  10. ├─bin
  11. ├─Debug
  12. MyGameServer.dll
  13. MyGameServer.pdb
  14. └─Release
  15. ├─Handler------------------------------------#处理请求
  16. BaseHandler.cs-------------------------#基本
  17. DefaultHandler.cs----------------------#
  18. LoginHandler.cs------------------------#登录
  19. RegisterHandler.cs---------------------#注册
  20. SyncPlayerHandler.cs-----------------#同步客户端
  21. SyncPositionHandler.cs---------------#同步位置信息
  22. ├─Manager
  23. IUserManager.cs------------------------#User表增删改查接口
  24. UserManager.cs-------------------------#User表增删改查
  25. ├─Mappings
  26. User.hbm.xml---------------------------#User表的hibernate配置文件
  27. ├─Model
  28. User.cs----------------------------------#User表的类
  29. ├─obj
  30. └─Debug
  31. DesignTimeResolveAssemblyReferencesInput.cache
  32. MyGameServer.csproj.FileListAbsolute.txt
  33. MyGameServer.csprojResolveAssemblyReference.cache
  34. MyGameServer.dll------------------#放入Photon的全项目文件
  35. MyGameServer.pdb
  36. TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
  37. TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
  38. TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
  39. └─TempPE
  40. ├─Properties
  41. AssemblyInfo.cs
  42. └─Threads--------------------------------------#线程
  43. SyncPositionThread.cs

下载服务器应用:.net Framework 3.5

只能3.5其他不行

3个方法:
1、
服务器管理器—仪表板—添加角色和功能
一直下一步到“确认”的指定备用源路径

  1. 可以先不填、不行在加
  2. D:\Sources\SxS

2、
https://dotnet.microsoft.com/download
下载有Framework、下载有visualstudio的
3、
https://msdn.itellyou.cn
工具和资源

下载服务器应用:visualstudio

https://msdn.itellyou.cn
开发人员工具

设置visualstudio

下载C#插件

下载服务器应用:Photon2 Server 的 Server

Photon官网:
有server(系统)和plugin(插件)选,选server(系统)
是一个Photon-OnPremise-Server-SDK_v4-0-29-11263.exe文件,是一个压缩包

解压到D:就可以,但不要解压在中文目录
目录:
-|build
-|deploy———————部署核心(有启动文件)
-|doc————————-文档(API)
-|lib
-|src-server—————-源码

deploy文件夹:
-|bin_tools
-|bin_32———————启动Photon2 Server
-|bin_win64—————-启动Photon2 Server
-|CounterPublisher——应用
-|Loadbalancing———-应用负载均衡,管理平衡多个服务器端
-|Plugins
-|Policy

启动PhotonControl可以管理多个游戏/应用

看是32/64位的PhotonControl.exe

从listen20ccu 扩展到100ccu

官网登录账号
your servers 可以下载一个license授权文件
邮箱名字.Photon-vX.free.100-ccu.license
把这个文件放到bin_win64/32文件夹里,和PhotonControl.exe相同目录
重启PhotonControl.exe

启动程序和查看日志

左下角的托盘
可以启动:Loadbalancing和MMO demo
日志:Open logs

配置文件PhotonServer.config

|<configuration></configuration>
|—<Loadbalancing></Loadbalancing>——-应用负载均衡,管理平衡多个服务器端
|—<MMODemo></MMODemo>
—|—Displayname=”显示名字”
—|—<UDPListeners></UDPListeners>UDP协议0.0.0.0代表所有ip
—|—<TCPListeners></TCPListeners>TCP协议0.0.0.0代表所有ip
—|—<PolicyFileListeners></PolicyFileListeners>端口
—|—<WebSocketListener></WebSocketListener>端口
—|—<runtime></runtime>内核
—|—<applications></applications>可以有多个应用
—|—|—<application></application>

HTTP、UDP、TCP协议
HTTP:访问网站
UDP:数据传输、下载、聊天(不是很稳定、快)(PhotonServer解决了UDP的不稳定)
TCP:数据传输、下载、聊天(比较稳定、慢)

application:
Name=名字可以自己定义
BaseDirectory=deploy文件夹的文件名,需要把文件上传到此处
Assembly=程序集的名字
Type=指定主程序
ForceAutoRestart=是否自动重启true/false
ExcludeFiles=

复制一个MMoDemo修改为自己的

共11个位置

修改config文件

C:\Photon-OnPremise-Server-SDK_v4-0-29-11263\deploy\bin_Win64\PhotonServer.config

  1. <!-- Instance settings -->
  2. <MyGameInstance
  3. MaxMessageSize="512000"
  4. MaxQueuedDataPerPeer="512000"
  5. PerPeerMaxReliableDataInTransit="51200"
  6. PerPeerTransmitRateLimitKBSec="256"
  7. PerPeerTransmitRatePeriodMilliseconds="200"
  8. MinimumTimeout="5000"
  9. MaximumTimeout="30000"
  10. DisplayName="Mygame"
  11. >
  12. <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
  13. <!-- Port 5055 is Photon's default for UDP connections. -->
  14. <UDPListeners>
  15. <UDPListener
  16. IPAddress="0.0.0.0"
  17. Port="5055"
  18. OverrideApplication="MyGame1">
  19. </UDPListener>
  20. </UDPListeners>
  21. <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
  22. <!-- Port 4530 is Photon's default for TCP connecttions. -->
  23. <!-- A Policy application is defined in case that policy requests are sent to this listener (known bug of some some flash clients) -->
  24. <TCPListeners>
  25. <TCPListener
  26. IPAddress="0.0.0.0"
  27. Port="4530"
  28. PolicyFile="Policy\assets\socket-policy.xml"
  29. InactivityTimeout="10000"
  30. OverrideApplication="MyGame1"
  31. >
  32. </TCPListener>
  33. </TCPListeners>
  34. <!-- Defines the Photon Runtime Assembly to use. -->
  35. <Runtime
  36. Assembly="PhotonHostRuntime, Culture=neutral"
  37. Type="PhotonHostRuntime.PhotonDomainManager"
  38. UnhandledExceptionPolicy="Ignore">
  39. </Runtime>
  40. <!-- Defines which applications are loaded on start and which of them is used by default. Make sure the default application is defined. -->
  41. <!-- Application-folders must be located in the same folder as the bin_win32 folders. The BaseDirectory must include a "bin" folder. -->
  42. <Applications Default="MyGame1">
  43. <!-- MMO Demo Application -->
  44. <Application
  45. Name="MyGame1"
  46. BaseDirectory="MyGameServer"
  47. Assembly="MyGameServer"
  48. Type="MyGameServer.MyGameServer"
  49. ForceAutoRestart="true"
  50. WatchFiles="dll;config"
  51. ExcludeFiles="log4net.config">
  52. </Application>
  53. </Applications>
  54. </MyGameInstance>

解释PhotonServer.config

  1. <!-- Instance settings -->
  2. <MyGameInstance #######名字+Instance(随意的)
  3. MaxMessageSize="512000"
  4. MaxQueuedDataPerPeer="512000"
  5. PerPeerMaxReliableDataInTransit="51200"
  6. PerPeerTransmitRateLimitKBSec="256"
  7. PerPeerTransmitRatePeriodMilliseconds="200"
  8. MinimumTimeout="5000"
  9. MaximumTimeout="30000"
  10. DisplayName="Mygame" #######名字(右下角显示的名字)
  11. >
  12. <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
  13. <!-- Port 5055 is Photon's default for UDP connections. -->
  14. <UDPListeners>
  15. <UDPListener
  16. IPAddress="0.0.0.0"
  17. Port="5055"
  18. OverrideApplication="MyGame1"> #######名字+数字,与下方application的name一致
  19. </UDPListener>
  20. </UDPListeners>
  21. <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->
  22. <!-- Port 4530 is Photon's default for TCP connecttions. -->
  23. <!-- A Policy application is defined in case that policy requests are sent to this listener (known bug of some some flash clients) -->
  24. <TCPListeners>
  25. <TCPListener
  26. IPAddress="0.0.0.0"
  27. Port="4530"
  28. PolicyFile="Policy\assets\socket-policy.xml"
  29. InactivityTimeout="10000"
  30. OverrideApplication="MyGame1" #######名字+数字,与下方applicationname一致
  31. >
  32. </TCPListener>
  33. </TCPListeners>
  34. <!-- Defines the Photon Runtime Assembly to use. -->
  35. <Runtime
  36. Assembly="PhotonHostRuntime, Culture=neutral"
  37. Type="PhotonHostRuntime.PhotonDomainManager"
  38. UnhandledExceptionPolicy="Ignore">
  39. </Runtime>
  40. <!-- Defines which applications are loaded on start and which of them is used by default. Make sure the default application is defined. -->
  41. <!-- Application-folders must be located in the same folder as the bin_win32 folders. The BaseDirectory must include a "bin" folder. -->
  42. <Applications Default="MyGame1">
  43. <!-- MMO Demo Application -->
  44. <Application
  45. Name="MyGame1" #######名字+数字
  46. BaseDirectory="MyGameServer" #######文件夹名字
  47. Assembly="MyGameServer" #######程序集
  48. Type="MyGameServer.MyGameServer" #######主类.启动方法
  49. ForceAutoRestart="true"
  50. WatchFiles="dll;config"
  51. ExcludeFiles="log4net.config">
  52. </Application>
  53. </Applications>
  54. </MyGameInstance>
  • 启动
  • 看3个日志
    C:\Photon-OnPremise-Server-SDK_v4-0-29-11263\deploy\bin_Win64\log\PhotonCLR.log——————————Photon的配置信息、Listen的信息
    C:\Photon-OnPremise-Server-SDK_v4-0-29-11263\deploy\bin_Win64\log\Photon-MyGameServer-日期.log——-Photon启动顺序的信息输出
    C:\Photon-OnPremise-Server-SDK_v4-0-29-11263\deploy\log\MyGame.Server.log————————自己配置的信息输出
    log.Info(“初始化完成”);