当前位置: 首页 > news >正文

个人网站建设的过程大连建设网站哪家好

个人网站建设的过程,大连建设网站哪家好,腾讯企业邮箱购买,邢台网站制作的地方文章目录 Unity进阶--通过PhotonServer实现联网登录注册功能(服务器端)--PhotonServer(二)服务器端大体结构图BLL层#xff08;控制层#xff09;DAL层#xff08;数据控制层#xff09;模型层DLC 服务器配置类 发送消息类 以及消息类 Unity进阶–通过PhotonServer实现联网… 文章目录 Unity进阶--通过PhotonServer实现联网登录注册功能(服务器端)--PhotonServer(二)服务器端大体结构图BLL层控制层DAL层数据控制层模型层DLC 服务器配置类 发送消息类 以及消息类 Unity进阶–通过PhotonServer实现联网登录注册功能(服务器端)–PhotonServer(二) 如何配置PhotonServer服务器https://blog.csdn.net/abaidaye/article/details/132096415 服务器端 大体结构图 结构图示意 BLL层控制层 总管理类 using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace PhotonServerFirst.Bll {public class BLLManager{private static BLLManager bLLManager;public static BLLManager Instance{get{if(bLLManager null){bLLManager new BLLManager();}return bLLManager;}}//登录注册管理public IMessageHandler accountBLL;private BLLManager(){accountBLL new Account.AccountBLL();}} } 控制层接口 using Net;namespace PhotonServerFirst.Bll {public interface IMessageHandler{//处理客户端断开的后续工作void OnDisconnect(PSpeer peer);//处理客户端的请求void OnOperationRequest(PSpeer peer, PhotonMessage message);} } 登录注册控制类 using Net; using PhotonServerFirst.Dal;namespace PhotonServerFirst.Bll.Account {class AccountBLL : IMessageHandler{public void OnDisconnect(PSpeer peer){throw new System.NotImplementedException();}public void OnOperationRequest(PSpeer peer, PhotonMessage message){//判断命令switch (message.Command){case MessageType.Account_Register:Register(peer, message);break;case MessageType.Account_Login:Login(peer, message);break;}}//注册请求 0账号1密码void Register(PSpeer peer, PhotonMessage message){object[] objs (object[])message.Content;//添加用户int res DAlManager.Instance.accountDAL.Add((string)objs[0],(string)objs[1]);//服务器响应SendMessage.Send(peer, MessageType.Type_Account, MessageType.Account_Register_Res, res);}//登陆请求 0账号1密码void Login(PSpeer peer, PhotonMessage message){object[] objs (object[])message.Content;//登录int res DAlManager.Instance.accountDAL.Login(peer, (string)objs[0], (string)objs[1]);//响应SendMessage.Send(peer, MessageType.Type_Account, MessageType.Account_Login_res, res);}} } DAL层数据控制层 总数据管理层 using PhotonServerFirst.Bll; using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace PhotonServerFirst.Dal {class DAlManager{private static DAlManager dALManager;public static DAlManager Instance{get{if (dALManager null){dALManager new DAlManager();}return dALManager;}}//登录注册管理public AccountDAL accountDAL;private DAlManager(){accountDAL new AccountDAL();}} } 登录注册数据管理层 using PhotonServerFirst.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace PhotonServerFirst.Dal {class AccountDAL{/// summary/// 保存注册的账号/// /summaryprivate ListAccountModel accountList new ListAccountModel();private int id 1;///summary///保存已经登录的账号/// /summaryprivate DictionaryPSpeer, AccountModel peerAccountDic new DictionaryPSpeer, AccountModel();///summary/// 添加账号////summary///param nameaccount 用户名/param///param namepassword密码/param///returns1 成功 -1账号已存在 0失败/returnspublic int Add(string account, string password){//如果账号已经存在foreach (AccountModel model in accountList){if (model.Account account){return -1;}}//如果不存在AccountModel accountModel new AccountModel();accountModel.Account account;accountModel.Password password;accountModel.ID id;accountList.Add(accountModel);return 1;}/// summary/// 登录账号/// /summary/// param namepeer连接对象/param/// param nameaccount账号/param/// param namepassword密码/param/// returns登陆成功返回账号id -1已经登陆 0用户名密码错误/returnspublic int Login(PSpeer peer, string account, string password){//是否已经登陆foreach (AccountModel model in peerAccountDic.Values){if (model.Account account){return -1;}}//判断用户名密码是否正确foreach (AccountModel model in accountList){if (model.Account account model.Password password){peerAccountDic.Add(peer, model);return model.ID;}}return 0;}} } 模型层 登录注册层 using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace PhotonServerFirst.Model {/// summary/// 账号模型/// /summaryclass AccountModel{public int ID;public string Account; public string Password;} } DLC 服务器配置类 发送消息类 以及消息类 服务器配置类 using Photon.SocketServer; using ExitGames.Logging; using ExitGames.Logging.Log4Net; using log4net.Config; using System.IO;namespace PhotonServerFirst {public class PSTest : ApplicationBase{//日志需要的public static readonly ILogger log LogManager.GetCurrentClassLogger();protected override PeerBase CreatePeer(InitRequest initRequest){ return new PSpeer(initRequest);}//初始化protected override void Setup(){InitLog();}//server端关闭的时候protected override void TearDown(){}#region 日志/// summary/// 初始化日志以及配置/// /summaryprivate void InitLog(){//日志的初始化log4net.GlobalContext.Properties[Photon:ApplicationLogPath] this.ApplicationRootPath \bin_Win64\log;//设置日志的路径FileInfo configFileInfo new FileInfo(this.BinaryPath \log4net.config);//获取配置文件if (configFileInfo.Exists){//对photonserver设置日志为log4netLogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);XmlConfigurator.ConfigureAndWatch(configFileInfo);log.Info(初始化成功);}}#endregion } } 服务器面向客户端类 using System; using System.Collections.Generic; using Net; using Photon.SocketServer; using PhotonHostRuntimeInterfaces; using PhotonServerFirst.Bll;namespace PhotonServerFirst {public class PSpeer : ClientPeer{public PSpeer(InitRequest initRequest) : base(initRequest){}//处理客户端断开的后续工作protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail){//关闭管理器BLLManager.Instance.accountBLL.OnDisconnect(this);}//处理客户端的请求protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters){var dic operationRequest.Parameters;//转为PhotonMessagePhotonMessage message new PhotonMessage();message.Type (byte)dic[0];message.Command (int)dic[1];Listobject objs new Listobject();for (byte i 2; i dic.Count; i){objs.Add(dic[i]);}message.Content objs.ToArray();//消息分发switch (message.Type){case MessageType.Type_Account:BLLManager.Instance.accountBLL.OnOperationRequest(this, message); break;case MessageType.Type_User:break;}}} } 消息类 因为这个类是unity和服务器端都需要有的所以最好生成为dll文件放进unitynet3.5以下 namespace Net {public class PhotonMessage{public byte Type;public int Command;public object Content;public PhotonMessage() { }public PhotonMessage(byte type, int command, object content){Type type;Command command;Content content;}}//消息类型public class MessageType{public const byte Type_Account 1;public const byte Type_User 2;//注册账号public const int Account_Register 100;public const int Account_Register_Res 101;//登陆public const int Account_Login 102;public const int Account_Login_res 103;} } 发送消息类 using Photon.SocketServer; using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace PhotonServerFirst {class SendMessage{/// summary/// 发送消息/// / summary/// param name peer 连接对象 / param /// param nametype类型/param/// param namecommand 命令/param/// param name objs 参数 / param public static void Send(PSpeer peer, byte type,int command,params object[] objs){Dictionarybyte, object dic new Dictionarybyte, object(); dic.Add(0, type);dic.Add(1, command);byte i 2;foreach (object o in objs){dic.Add(i,o);}EventData ed new EventData(0, dic);peer.SendEvent(ed, new SendParameters());}} }
http://www.zqtcl.cn/news/576471/

相关文章:

  • 自做刷赞网站山东东成建设咨询有限公司网站
  • 泉州网站制作推广网站建设一年多少
  • 超大型网站建设公司网站打开显示建设中
  • 惠东县网站建设建设方案
  • 怎么把做的网站发布长春建网站
  • 织梦网站手机端郑州网站制作公司名单
  • 如何建设网站安全网站桥页也叫
  • 南浔网站建设昆山智能网站开发
  • 阿里云可以做电商网站吗杭州网站建设浙江
  • 查询网站备案进度网站建设推广
  • 怎么做公司网站需要什么科目高端网站建设教学
  • 资讯平台网站模板中企中立做的网站好吗
  • 网站开发人员配备山西省吕梁市简介
  • 网站注销主体注销中国建设教育协会培训报名网站
  • 电商网站设计思想建设化妆品网站的成本
  • 做房产网站能赚钱吗深圳龙华区邮政编码
  • 网站开发素材代码手机网站 win8风格
  • 免费推广网站软件班级网站怎么做ppt模板
  • 在线做任务的网站有哪些wordpress ui 插件
  • 竣工验收备案表查询网站优化大师win10能用吗
  • php 网站管理系统做生鲜管理系统的网站
  • 昆山建设工程招聘信息网站业绩显示屏 东莞网站建设技术支持
  • 百度我的网站广东广州网站建设
  • 怎么提高网站流量沈阳有资质做网站的公司有哪些
  • 内蒙古住房与城乡建设厅网站网址微信可以上网
  • 如何网站seo中国化工第九建设公司网站
  • 无锡网站推广优化公司单位网站建设必要性
  • 网站建设丶金手指花总12网站建设是怎么挣钱
  • 网站开发都是用什么框架广西建设网人员查询网
  • 做购物网站怎么写开题报告中山如何建网站