Photon Server伺服务器在LoadBalancing的基础上扩展登陆服务

一,如何创建一个Photon Server服务

  参见此博客 快速了解和使用Photon Server

二, 让LoadBalancing与自己的服务一起启动

  原Photonserver.config文件中需要改动的地方有4处

  1.  <UDPListeners> 标签

    Udp监听端口

      <UDPListeners>
			<UDPListener
				IPAddress="0.0.0.0"
				Port="5055"
				OverrideApplication="Master">
			</UDPListener>
			<UDPListener
				IPAddress="0.0.0.0"
				Port="5056"
				OverrideApplication="Game">
			</UDPListener>
			<UDPListener
				IPAddress="0.0.0.0"
				Port="5057"
				OverrideApplication="LoginServer">
			</UDPListener>
		</UDPListeners>

  这里配置我自己的服务 LoginServer 监听端口为5057 所以Unity中链接服务器的端口也要改动

    address = "127.0.0.1:5057"; //连接本机ip,端口5055是Photon Lobalancing服务的默认端口

    Server = "LoginServer";
    peer = new PhotonPeer(this, ConnectionProtocol.Udp); //默认使用udp协议
    peer.Connect(address, Server);  

  2.  <TCPListeners> 标签

    TCP监控端口

    同样的添加配置    

			<TCPListener
				IPAddress="0.0.0.0"
				Port="4532"
				OverrideApplication="LoginServer"
				PolicyFile="Policy\assets\socket-policy.xml"
				InactivityTimeout="10000">
			</TCPListener>

3.  <WebSocketListeners>

    WebSocket兼容监听    

			<WebSocketListener
				IPAddress="0.0.0.0"
				Port="9092"
				DisableNagle="true"
				InactivityTimeout="10000"
				OverrideApplication="LoginServer">
			</WebSocketListener>

   4.  <Applications>标签

  保留Master Game 等原来的标签

		<Applications Default="Master">
			<Application
				Name="LoginServer"
				BaseDirectory="LoginServer"
				Assembly="LoginServer"
				Type="LoginServer.LoginServer"
				ForceAutoRestart="true"
				WatchFiles="dll;config"
				ExcludeFiles="log4net.config"
			>
			</Application>
			.              .              .
		</Applications>

  完整的Photonserver.config文件  

<?xml version="1.0" encoding="Windows-1252"?>
<!--
    (c) 2015 by Exit Games GmbH, http://www.exitgames.com
    Photon server configuration file.
    For details see the photon-config.pdf.

    This file contains two configurations:

        "LoadBalancing"
                Loadbalanced setup for local development: A Master-server and a game-server.
                Starts the apps: Game, Master, CounterPublisher
                Listens: udp-port 5055, tcp-port: 4530, 843 and 943        

-->

<Configuration>
    <!-- Multiple instances are supported. Each instance has its own node in the config file. -->

    <LoadBalancing
        MaxMessageSize="512000"
        MaxQueuedDataPerPeer="512000"
        PerPeerMaxReliableDataInTransit="51200"
        PerPeerTransmitRateLimitKBSec="256"
        PerPeerTransmitRatePeriodMilliseconds="200"
        MinimumTimeout="5000"
        MaximumTimeout="30000"
        DisplayName="LoadBalancing (MyCloud)">

        <!-- 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="Master">
            </UDPListener>
            <UDPListener
                IPAddress="0.0.0.0"
                Port="5056"
                OverrideApplication="Game">
            </UDPListener>
            <UDPListener
                IPAddress="0.0.0.0"
                Port="5057"
                OverrideApplication="LoginServer">
            </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 -->
            <TCPListener
                IPAddress="0.0.0.0"
                Port="4530"
                OverrideApplication="Master"
                PolicyFile="Policy\assets\socket-policy.xml"
                InactivityTimeout="10000"
                >
            </TCPListener>

            <TCPListener
                IPAddress="0.0.0.0"
                Port="4531"
                OverrideApplication="Game"
                PolicyFile="Policy\assets\socket-policy.xml"
                InactivityTimeout="10000">
            </TCPListener>
            <TCPListener
                IPAddress="0.0.0.0"
                Port="4532"
                OverrideApplication="LoginServer"
                PolicyFile="Policy\assets\socket-policy.xml"
                InactivityTimeout="10000">
            </TCPListener>

            <!-- DON‘T EDIT THIS. TCP listener for GameServers on Master application -->
            <TCPListener
                IPAddress="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 -->
          <PolicyFileListener
            IPAddress="0.0.0.0"
            Port="843"
            PolicyFile="Policy\assets\socket-policy.xml">
          </PolicyFileListener>
          <PolicyFileListener
            IPAddress="0.0.0.0"
            Port="943"
            PolicyFile="Policy\assets\socket-policy-silverlight.xml">
          </PolicyFileListener>
        </PolicyFileListeners>

        <!-- WebSocket (and Flash-Fallback) compatible listener -->
        <WebSocketListeners>
            <WebSocketListener
                IPAddress="0.0.0.0"
                Port="9090"
                DisableNagle="true"
                InactivityTimeout="10000"
                OverrideApplication="Master">
            </WebSocketListener>

            <WebSocketListener
                IPAddress="0.0.0.0"
                Port="9091"
                DisableNagle="true"
                InactivityTimeout="10000"
                OverrideApplication="Game">
            </WebSocketListener>
            <WebSocketListener
                IPAddress="0.0.0.0"
                Port="9092"
                DisableNagle="true"
                InactivityTimeout="10000"
                OverrideApplication="LoginServer">
            </WebSocketListener>
        </WebSocketListeners>

        <!-- 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="Master">
            <Application
                Name="LoginServer"
                BaseDirectory="LoginServer"
                Assembly="LoginServer"
                Type="LoginServer.LoginServer"
                ForceAutoRestart="true"
                WatchFiles="dll;config"
                ExcludeFiles="log4net.config"
            >
            </Application>
            <Application
                Name="Master"
                BaseDirectory="LoadBalancing\Master"
                Assembly="Photon.LoadBalancing"
                Type="Photon.LoadBalancing.MasterServer.MasterApplication"
                ForceAutoRestart="true"
                WatchFiles="dll;config"
                ExcludeFiles="log4net.config"
                >
            </Application>
            <Application
                Name="Game"
                BaseDirectory="LoadBalancing\GameServer"
                Assembly="Photon.LoadBalancing"
                Type="Photon.LoadBalancing.GameServer.GameApplication"
                ForceAutoRestart="true"
                WatchFiles="dll;config"
                ExcludeFiles="log4net.config">
            </Application>

            <!-- CounterPublisher Application -->
            <Application
                Name="CounterPublisher"
                BaseDirectory="CounterPublisher"
                Assembly="CounterPublisher"
                Type="Photon.CounterPublisher.Application"
                ForceAutoRestart="true"
                WatchFiles="dll;config"
                ExcludeFiles="log4net.config">
            </Application>
        </Applications>
    </LoadBalancing>    

    <!-- Instance settings -->
    <MMoDemo
        MaxMessageSize="512000"
        MaxQueuedDataPerPeer="512000"
        PerPeerMaxReliableDataInTransit="51200"
        PerPeerTransmitRateLimitKBSec="256"
        PerPeerTransmitRatePeriodMilliseconds="200"
        MinimumTimeout="5000"
        MaximumTimeout="30000"
        DisplayName="MMO Demo"
        >

        <!-- 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="MMoDemo">
            </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="MMoDemo"
                >
            </TCPListener>
        </TCPListeners>

        <!-- Policy request listener for Unity and Flash (port 843) and Silverlight (port 943)  -->
        <PolicyFileListeners>
          <!-- multiple Listeners allowed for different ports -->
          <PolicyFileListener
            IPAddress="0.0.0.0"
            Port="843"
            PolicyFile="Policy\assets\socket-policy.xml"
            InactivityTimeout="10000">
          </PolicyFileListener>
          <PolicyFileListener
            IPAddress="0.0.0.0"
            Port="943"
            PolicyFile="Policy\assets\socket-policy-silverlight.xml"
            InactivityTimeout="10000">
          </PolicyFileListener>
        </PolicyFileListeners>

        <!-- WebSocket (and Flash-Fallback) compatible listener -->
        <WebSocketListeners>
            <WebSocketListener
                IPAddress="0.0.0.0"
                Port="9090"
                DisableNagle="true"
                InactivityTimeout="10000"
                OverrideApplication="MMoDemo">
            </WebSocketListener>
        </WebSocketListeners>

        <!-- 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="MMoDemo">

            <!-- MMO Demo Application -->
            <Application
                Name="MMoDemo"
                BaseDirectory="MmoDemo"
                Assembly="Photon.MmoDemo.Server"
                Type="Photon.MmoDemo.Server.PhotonApplication"
                ForceAutoRestart="true"
                WatchFiles="dll;config"
                ExcludeFiles="log4net.config">
            </Application>

            <!-- CounterPublisher Application -->
            <Application
                Name="CounterPublisher"
                BaseDirectory="CounterPublisher"
                Assembly="CounterPublisher"
                Type="Photon.CounterPublisher.Application"
                ForceAutoRestart="true"
                WatchFiles="dll;config"
                ExcludeFiles="log4net.config">
            </Application>    

        </Applications>
    </MMoDemo>

</Configuration>

unity 中使用 PhotonPeer 的时候要注意在销毁场景的时候关闭链接 peer.Disconnect();

 否则unity会在第二次运行的时候出现卡死的状态.

 PhotonPeer连接服务器的时候会创建一个网络线程,停止调试并不会自动的将这个线程结束,再次调试的时候Unity就会卡在PhotonPeer创建网络线程的操作上.......

  这是我的登陆服务

时间: 2024-10-09 02:21:28

Photon Server伺服务器在LoadBalancing的基础上扩展登陆服务的相关文章

概念DNG格式是在TIFF的基础上扩展出来的

http://blog.zhulong.com/blog/detail5212080.htmlhttp://blog.zhulong.com/blog/detail5212081.htmlhttp://blog.zhulong.com/blog/detail5212082.htmlhttp://blog.zhulong.com/blog/detail5212084.htmlhttp://blog.zhulong.com/blog/detail5212086.htmlhttp://blog.zhu

解决VS无法连接到已配置的开发web服务器或者部署在IIS上的web服务打不开的问题

其实这都是防火墙搞的怪 ,关闭防火墙即可 选择右边的,[打开或者关闭防火墙]

Photon Server LoadBalancing搭建

准备:申请3台Windows虚拟机. 3台虚拟机上都部署上Photon Server. 一.主虚拟机上部署MasterServer. (1)在第一台虚拟机中,部署的Photon Server目目录下找到Loadbalancing目录,删除GameServer文件夹 (2)修改Master的配置文件.Photon.LoadBalancing.dll.config (在目录Master/bin/中) (3)修改PhotonServer.config 配置文件.(在目录 bin_Win64/ 中) 删

CentOS6上DNS服务器的安装配置-基础篇

一. DNS简介: DNS(Domain Name System),是互联网的一种很重要的基础服务,DNS服务作为域名和IP地址相互映射的一个分布式数据库,能够使用户更方便的访问互联网,而不用去记住能够被机器直接读取的IP数串.通过主机名,最终得到该主机名对应的IP地址的过程叫做域名解析(或主机名解析).DNS协议运行在UDP协议之上,使用端口号53.当在DNS区域传送机制运行在TCP协议,使用端口号53. 二. DNS查询方式: DNS共有两种查询方法: 递归查询 由局部DNS服务器自己负责向

Photon Server

PhotonServer官网:https://www.photonengine.com/en/OnPremise 官网的帮助文档:Documentatain Photon Server是一款实时的Socket服务器和开发框架,快速.使用方便.容易扩展,服务端架构在Windows系统平台上,采用C#语言编写,Photon Server发布包括两个部分,Client SDK Release和Server SDK Update,Server SDK的版本是v2.4.5,而Client SDK的版本是v

阿里云ECSwindows server 2008服务器安全设置

最近我们Sinesafe安全公司在为客户使用阿里云ecs服务器做安全的过程中,发现服务器基础安全性都没有做.为了为站长们提供更加有效的安全基础解决方案,我们Sinesafe将对阿里云服务器win2008 系统进行基础安全部署实战过程! 比较重要的几部分 1.更改默认administrator用户名,复杂密码2.开启防火墙3.安装杀毒软件 1)新做系统一定要先打上补丁2)安装必要的杀毒软件3)删除系统默认共享 4)修改本地策略-->安全选项 交互式登陆:不显示最后的用户名 启用网络访问:不允许SA

阿里云Windows server 2008服务器搭建VPN 图文教程,购买境外服务器自建vpn,Win8/win10 连接VPN被阻止,出现812错误解决方法

阿里云Windows server 2008服务器搭建VPN 图文教程(超详细) 第一步:购买阿里云服务器,本文使用的是Windows Server 2008 R2 企业版64位中文版 IP地址:47.88.151.129,所属节点:亚太(新加坡) 服务器配置:2核,4GB,带宽10Mbps 第二步: 打开服务器管理器,点击添加角色,如下图: 本帖隐藏的内容然后弹出如下图所示,点击下一步: 点击后,如下图,勾选网络策略和网络服务,然后点击下一步: 接着继续点击下一步,直到弹出如下图所示的页面,勾

Microsoft server 2008服务器搭建~

搭建服务器 最近自己要搭建一个服务器,公司给我台式机,让我做服务器,这可难倒我了,我以前都是用的别人的服务器,没关系,自己百度,就可以了. (1).准备Microsoft server 2008 R2的光盘: (2).格式化台式机硬盘,也就是说,以前台式机装的是xp或者win7系统,现在要换成服务器了,就必须安装服务器的系统,服务器系统有linux和Microsoft,我们用的是 Microsoft server 2008服务器. (3).自己安装百度下连接:http://jingyan.bai

XenApp_XenDesktop_7.6实战篇之九:SQL Server数据库服务器规划及部署

安装SQL Server 数据库,用于支持Desktop Studio 和桌面云管理台数据存储和访问.在简单的POC测试中,数据库可以只配置单机:但数据库故障时,不但影响配置管理台,也会影响DDC的运作,新的用户会话将不能建立(不影响已建立的会话),因此在生产环境部署时,必须考虑SQLServer的高可用性.另外需要注意的是必需定期备份数据库,防止数据库故障时丢失数据,并且防止事务日志的不断增长.您需要规划每个数据库实例名称.数据库名称及数据库空间大小. 1.  SQL Server数据库服务器