1.在项目的引用中添加引用,添加的是PhotonServer的lib中的三个dll
ExitGamesLibs.dll
Photon.SocketServer.dll
PhotonHostRuntimeInterfaces.dll
2.将MyGameServer去继承ApplicationBase,并且引入相应命名空间
MyGameServer.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Photon.SocketServer;namespace RRGameServer
{//所有的Server,都要继承ApplicationBase,然后实现ApplicationBase的三个方法public class MyGameServer : ApplicationBase{//当有一个客户端连接上以后,就会执行此方法protected override PeerBase CreatePeer(InitRequest initRequest){return new ClientPeer(initRequest);}//服务器初始化函数protected override void Setup(){}//服务器关闭函数protected override void TearDown(){}}
}
3.在项目中添加一个新的类:ClinetPeer,并且继承Photon.SocketServer.ClientPeer,且引用相应命名空间
ClientPeer.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Photon.SocketServer;
using PhotonHostRuntimeInterfaces;namespace RRGameServer
{class ClientPeer : Photon.SocketServer.ClientPeer{public ClientPeer(InitRequest initRequest) : base(initRequest){}//当每个客户端断开时protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail){}//当客户端发起请求的时候protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters){}}
}
4.生成dll文件
5.在PhotonServer的deploy文件夹下创建一个RRGameServer的文件夹,并且把我们新生成所有文件都放进去