热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

PhotonServer创建APPServer和Client类

1.在项目的引用中添加引用,添加的是PhotonServer的lib中的三个dllExitGamesLibs.dllPhoton.SocketServer.dll

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的文件夹,并且把我们新生成所有文件都放进去

 



推荐阅读
author-avatar
coco昵称不可用
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有