photon 配置及日志输出
来源:互联网 发布:linux系统api有哪些 编辑:程序博客网 时间:2024/05/19 11:47
下载安装photon好
下载证书添加到 deploy /bin_Win64 文件夹中
打开visio 新建类库 添加引用ExitGames.Logging.Log4Net.dll,ExitGamesLibs.dll,log4net.dll,Photon.SocketServer.dll,PhotonHostRuntimeInterfaces.dll
及Litjson.dll
新建类 继承自ApplicationBase
//客户端连接 protected override PeerBase CreatePeer(InitRequest initRequest) { return new MobaClient(initRequest); } //服务器初始化 protected override void Setup() { InitLogging(); LoginInfo("服务器初始化成功"); } //服务器断开 protected override void TearDown() { LoginInfo("服务器断开"); } #region 日志功能 private static readonly ILogger log = ExitGames.Logging.LogManager.GetCurrentClassLogger(); private void InitLogging() { ExitGames.Logging.LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance); GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(this.ApplicationRootPath, "log"); GlobalContext.Properties["LogFileName"] = "MOBA" + this.ApplicationName; XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(this.BinaryPath, "log4net.config"))); } public static void LoginInfo(string text) { log.Info(text.ToString()); } #endregion新建类继承自ClientPeer
public MobaClient(InitRequest initRequest) : base(initRequest) { } //客户端断开连接 protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail) { } //客户端发起请求 protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters) { }之后更改deploy\bin_Win64 目录下的PhotonServer.config 这个配置文件
复制LoadBalancing标签内的代码进行配置
<TestGameMaxMessageSize="512000"MaxQueuedDataPerPeer="512000"PerPeerMaxReliableDataInTransit="51200"PerPeerTransmitRateLimitKBSec="256"PerPeerTransmitRatePeriodMilliseconds="200"MinimumTimeout="5000"MaximumTimeout="30000"DisplayName="MOBA (Server)">//更改成自己的项目服务器名称 <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. --> <!-- Port 5055 is Photon's default for UDP connections. --> <UDPListeners> <UDPListenerIPAddress="0.0.0.0"Port="5055"OverrideApplication="MOBA">//UDP监听 </UDPListener> </UDPListeners> <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. --> <TCPListeners> <!-- TCP listener for Game clients on Master application --> <TCPListenerIPAddress="0.0.0.0"Port="4530"OverrideApplication="MOBA"//TCP监听PolicyFile="Policy\assets\socket-policy.xml"InactivityTimeout="10000"> </TCPListener> <!-- DON'T EDIT THIS. TCP listener for GameServers on Master application --> <TCPListenerIPAddress="0.0.0.0"Port="4520"> </TCPListener> </TCPListeners> <!-- Policy request listener for Unity and Flash (port 843) and Silverlight (port 943) --> <PolicyFileListeners> <!-- multiple Listeners allowed for different ports --> <PolicyFileListenerIPAddress="0.0.0.0"Port="843"PolicyFile="Policy\assets\socket-policy.xml"> </PolicyFileListener> <PolicyFileListenerIPAddress="0.0.0.0"Port="943"PolicyFile="Policy\assets\socket-policy-silverlight.xml"> </PolicyFileListener> </PolicyFileListeners> <!-- Defines the Photon Runtime Assembly to use. --> <RuntimeAssembly="PhotonHostRuntime, Culture=neutral"Type="PhotonHostRuntime.PhotonDomainManager"UnhandledExceptionPolicy="Ignore"> </Runtime> <!-- Defines which applications are loaded on start and which of them is used by default. Make sure the default application is defined. --> <!-- Application-folders must be located in the same folder as the bin_win32 folders. The BaseDirectory must include a "bin" folder. --> <Applications Default="MOBA"> <ApplicationName="MOBA"BaseDirectory="MOBA"Assembly="MOBAServer"Type="MOBAServer.MOBAApplication" //命名空间及基类ForceAutoRestart="true"WatchFiles="dll;config"ExcludeFiles="log4net.config"> </Application> <!-- CounterPublisher Application --> <ApplicationName="CounterPublisher"BaseDirectory="CounterPublisher"Assembly="CounterPublisher"Type="Photon.CounterPublisher.Application"ForceAutoRestart="true"WatchFiles="dll;config"ExcludeFiles="log4net.config"> </Application> </Applications> </TestGame>将其发布在deploy目录下
之后运行启动后 就可以看见日志内容了
0 0
- photon 配置及日志输出
- Photon Server游戏服务器从零开始学习(二) Log日志文件配置与输出
- Log4j日志输出配置及Demo
- 【系统学习SpringBoot】SpringBoot配置logging日志及输出日志
- feign的基础配置及修改日志输出类型
- 配置mysql日志输出
- logback配置日志输出
- Log4J日志输出配置
- ibatis日志输出配置
- 配置photon server log
- Log4J日志配置详解和自定义log4j日志级别及输出日志到不同文件实现方法
- Log4J日志配置详解和自定义log4j日志级别及输出日志到不同文件实现方法
- ACE_DEBUG介绍及日志输出
- ACE_DEBUG介绍及日志输出
- Android单元测试及日志输出
- 单元测试及日志输出总结
- ACE_DEBUG介绍及日志输出
- ACE_DEBUG介绍及日志输出
- 编程这10年,那些事
- Fragment的应用之底部导航栏的实现(二)之应用ViewPager
- 放代码
- java实现单向链表--创建、遍历
- day27_struts2环境搭建&配置文件
- photon 配置及日志输出
- hdu 2072 单词数 set+按字符处理
- hibernate调优
- linux设置问题
- 扫雷
- 4月12日,TestMyThread,每日20行。
- Ajax基本案例详解之$.post的实现
- 全面了解Window
- 题目1024:畅通工程