Photon_部署PhotonServer 服务端项目_011
来源:互联网 发布:java模拟发送get请求 编辑:程序博客网 时间:2024/06/03 19:52
第一步创建项目
首先创建一个VS项目,不同的是这次创建的项目是类库
第二步创建部署的目录
在deploy目录下面创建MyGameServer目录,并在MyGameServer下创建bin目录
第三步修改项目的生成目录
因为此项目是一个类库项目,所以会生成一些文件
我们将这些文件直接放入第二步创建的目录中
这样在我们完成项目的时候选择项目,右键,点击生成就可以在此目录下面看到生成的文件了
第四步 添加必要的引用
第五步创建主类
创建MyGameServer类
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Photon.SocketServer;using ExitGames.Logging;using ExitGames.Logging.Log4Net;using System.IO;using log4net.Config;namespace MyGameServer{ //所有的server端 主类都要继承自ApplicationBase类 //ApplicationBase 是一个抽象类 我们需要实现他的所有的抽象方法 public class MyGameServer : ApplicationBase { //当一个客户端请求连接的时候 //我们使用peerbase 表示和一个客户端的连接 protected override PeerBase CreatePeer(InitRequest initRequest) { return new ClientPeer(initRequest); } //初始化 protected override void Setup() { } //Server端关闭的时候 protected override void TearDown() { } }}
第六步 创建一个用户连接类
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Photon;using Photon.SocketServer;using PhotonHostRuntimeInterfaces;namespace MyGameServer{ public class ClientPeer : Photon.SocketServer.ClientPeer { public ClientPeer(InitRequest initRequest) : base(initRequest) { } //断开连接 protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail) { throw new NotImplementedException(); } //发送请求 protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters) { throw new NotImplementedException(); } }}
第七步配置文件
该配置文件位于\deploy\bin_Win64文件夹下
此文件是一个文本文件,为了便于我们编辑我们可以使用VS打开
在此文件中Configurtion标签中包含两个系统自带的项目
LoadBalancing和MMoDemo
类似下面的图
我们可以复制其中一个开始更改我们现在要部署的项目
<!-- Instance settings --> <!-- DisplayName 就是项目启动时启动的名字 --> <MyGameInstance MaxMessageSize="512000" MaxQueuedDataPerPeer="512000" PerPeerMaxReliableDataInTransit="51200" PerPeerTransmitRateLimitKBSec="256" PerPeerTransmitRatePeriodMilliseconds="200" MinimumTimeout="5000" MaximumTimeout="30000" DisplayName="My Game" > <!-- 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> <UDPListener IPAddress="0.0.0.0" Port="5055" OverrideApplication="MyGame1"> </UDPListener> </UDPListeners> <!-- 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 are sent to this listener (known bug of some some flash clients) --> <TCPListeners> <TCPListener IPAddress="0.0.0.0" Port="4530" PolicyFile="Policy\assets\socket-policy.xml" InactivityTimeout="10000" OverrideApplication="MyGame1" > </TCPListener> </TCPListeners> <!-- Defines the Photon Runtime Assembly to use. --> <Runtime Assembly="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="MyGame1"> <!-- MMO Demo Application --> <!--BaseDirectory="MyGameServer" 我们在deploy下创建的目录--> <!--Assembly="MyGameServer" 程序集--> <!--Type="MyGameServer.MyGameServer" 就是主类的路径 含义:在MyGameServer命名空间下的MyGameServer类--> <Application Name="MyGame1" BaseDirectory="MyGameServer" Assembly="MyGameServer" Type="MyGameServer.MyGameServer" ForceAutoRestart="true" WatchFiles="dll;config" ExcludeFiles="log4net.config"> </Application> </Applications> </MyGameInstance>
这样我们就可以启动自己的项目了
阅读全文
0 0
- Photon_部署PhotonServer 服务端项目_011
- Photon_配置PhotonServer的日志信息_012
- PhotonServer游戏服务器部署及日志输出
- 服务端自动部署静态项目的几种方法
- 项目实训-千寻-服务端代码部署阿里云
- CAS部署服务端
- Zabbix 服务端部署安装
- 远程服务端部署weblogic10
- CentOS6部署VNC服务端
- 如何部署Icinga服务端
- ELK服务端安装部署
- 搭建shadowsocks服务端部署
- svn服务端部署
- PhotonServer概念
- Photonserver 官方论坛
- PhotonServer初探
- PhotonServer介绍
- PhotonServer学习
- Redis简介及单机版安装教程
- 判断是否存在pdf阅读器
- 卷积神经网络概念与原理
- PostgreSQL数据库pg_test_timing学习使用
- hadoop的三大核心组件详解
- Photon_部署PhotonServer 服务端项目_011
- 535 Error:authentication failed
- Bootstrap Table 中文文档(完整翻译版)
- 10分钟Pandas教程
- 启用nginx status状态详解
- superset 开源数据可视化工具(For Apache Kylin)使用说明
- 计算列
- 变量和常量
- Caused by: java.lang.NoClassDefFoundError: org/apache/tomcat/util/descriptor/tld/TldParser