Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    12

    Chapter 10, Stub Photon: SendEvent() Client gets stuck at InitializingApplication

    Did Photon change anything or why can't i access the internal constructor 'PeerBase' as in the "Stub Photon" Video?
    I am using Photon v4.0.29.11263.

    Getting following Errors:
    - Cannot access internal constructor 'PeerBase' here.
    - 'PeerBase' does not contain a constructor that takes 1 arguments.

    I am a little confused atm., triple checked the code and the photon .dll references.

    Peer.cs
    Code:
    using Photon.SocketServer;
    using PhotonHostRuntimeInterfaces;
    
    namespace BuzzMMO.Server.Master
    {
    	public class Peer : PeerBase 
    	{
    		public Peer(InitRequest initRequest) : base(initRequest)
    		{
    		}
    
    		protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
    		{
    		}
    
    		protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
    		{
    		}
    	}
    }
    Last edited by Jupp; 03-17-2016 at 08:18 AM.

  2. #2
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    12
    Wow, i really can't figure out what's wrong :/

  3. #3
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    12
    Guess i figured it out now.

    Incase anyone wonders, ClientPeer replaces PeerBase

    https://doc.photonengine.com/en/onpr.../upgrade-guide

  4. #4
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    12
    Ran into another problem, seems i can't send Events.
    If i remove the SendEvent() call in the Peer.cs Class i can connect to the master Server, if i make use of SendEvent() within the Peer() constructor then the Unity Client gets stuck at "InitializingApplication" and gets "DisconnectedByServer" after a while.
    Even if i send only some random Text with SendEvent() the client gets stuck.

    I am just wondering if anyone else ran into an similiar issue?
    I am using the current Photon and Unity SDKs.
    Photon Server: v4.0.29.11263.exe
    Unity SDK: v4.0.5.1
    .NET SDK: v4.0.5.0

    Running Unity 5.3.3f1

    Peer.cs
    Code:
    using System.Collections.Generic;
    using System.Configuration;
    using Photon.SocketServer;
    using PhotonHostRuntimeInterfaces;
    
    namespace BuzzMMO.Server.Master
    {
    	public class Peer : ClientPeer
    	{
    		public Peer(InitRequest initRequest) : base(initRequest)
    		{
    			SendEvent(new EventData(
    				0, 
    				new Dictionary<byte, object>
    				{
    					{0, ConfigurationManager.AppSettings["RegionServers"] }
    				}), 
    				new SendParameters
    				{
    					Unreliable = false
    				});
    		}
    
    		protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
    		{
    		}
    
    		protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
    		{
    		}
    	}
    }
    Application.cs
    Code:
    using Photon.SocketServer;
    
    namespace BuzzMMO.Server.Master
    {
    	public class Application : ApplicationBase
    	{
    		protected override PeerBase CreatePeer(InitRequest initRequest)
    		{
    			return new Peer(initRequest);
    		}
    
    		protected override void Setup()
    		{
    		}
    
    		protected override void TearDown()
    		{
    		}
    	}
    }
    TestPhoton.cs
    Code:
    using System.Collections.Generic;
    using UnityEngine;
    using ExitGames.Client.Photon;
    
    public class TestPhoton : MonoBehaviour, IPhotonPeerListener
    {
    	private PhotonPeer _peer;
    	private List<PhotonPeer> _regionServers;
    
    	public void Awake()
    	{
    		_regionServers = new List<PhotonPeer>();
    		_peer = new PhotonPeer(this, ConnectionProtocol.Udp);
    		_peer.Connect("127.0.0.1:5055", "BuzzMMOMaster");
    	}
    
    	public void Update()
    	{
    		_peer.Service();
    		Debug.Log(_peer.PeerState.ToString());
    
    		foreach (var regionServer in _regionServers)
    			regionServer.Service();
    	}
    
    	public void OnApplicationQuit()
    	{
    		_peer.Disconnect();
    
    		foreach (var regionServer in _regionServers)
    			regionServer.Disconnect();
    	}
    
    	public void OnEvent(EventData eventData)
    	{		
    		var regionServers = eventData.Parameters[0].ToString().Split(',');
    		foreach (var server in regionServers)
    		{
    			var regionServer = new PhotonPeer(this, ConnectionProtocol.Udp);
    			regionServer.Connect(server, "BuzzMMORegion");
    			_regionServers.Add(regionServer);
    		}
    	}
    
    	public void DebugReturn(DebugLevel level, string message)
    	{
    	}
    
    	public void OnOperationResponse(OperationResponse operationResponse)
    	{
    	}
    
    	public void OnStatusChanged(StatusCode statusCode)
    	{
    		Debug.Log(string.Format("Status Changed: {0}", statusCode));
    	}
    }

  5. #5
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    12
    Alright, looks like you can't call SendEvent() anymore within the constructor with Photon 4.
    Got it working now, i also used the log4net logger, just for testing reasons.
    Well, maybe it will help someone who may run into same issues.

    I changed the code to the following:

    Peer.cs
    Code:
    using System.Collections.Generic;
    using System.Configuration;
    using ExitGames.Logging;
    using Photon.SocketServer;
    using PhotonHostRuntimeInterfaces;
    
    namespace BuzzMMO.Server.Master
    {
    	public class Peer : ClientPeer
    	{
    		private readonly ILogger Log = LogManager.GetCurrentClassLogger();
    
    		public Peer(InitRequest initRequest) : base(initRequest)
    		{
    			Log.Debug("Connection reveived from: " + initRequest.PhotonPeer.GetRemoteIP());
    		}
    
    		protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
    		{
    			switch (operationRequest.OperationCode)
    			{
    				case 1:
    					if (operationRequest.Parameters.ContainsKey(1))
    					{
    						Log.Debug("Received: " + operationRequest.Parameters[1]);
    
    						SendEvent(new EventData(
    							0,
    							new Dictionary<byte, object>
    							{
    								{0, ConfigurationManager.AppSettings["RegionServers"]}
    							}),
    							new SendParameters
    							{
    								Unreliable = false
    							});
    					}
    					break;
    				default:
    					Log.Debug("Unknown OperationRequest received.");
    					break;
    			}
    
    			
    		}
    
    		protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
    		{
    			Log.Debug("Client Disconnected");
    		}
    	}
    }
    Application.cs
    Code:
    using System.IO;
    using ExitGames.Logging;
    using ExitGames.Logging.Log4Net;
    using log4net.Config;
    using Photon.SocketServer;
    
    namespace BuzzMMO.Server.Master
    {
    	public class Application : ApplicationBase
    	{
    		protected override PeerBase CreatePeer(InitRequest initRequest)
    		{
    			return new Peer(initRequest);
    		}
    
    		protected override void Setup()
    		{
    			var file = new FileInfo(Path.Combine(BinaryPath, "log4net.config"));
    			if (file.Exists)
    			{
    				LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
    				XmlConfigurator.ConfigureAndWatch(file);
    			}
    		}
    
    		protected override void TearDown()
    		{
    		}
    	}
    }
    TestPhoton.cs
    Code:
    using System.Collections.Generic;
    using UnityEngine;
    using ExitGames.Client.Photon;
    
    public class TestPhoton : MonoBehaviour, IPhotonPeerListener
    {
    	private PhotonPeer _peer;
    	private List<PhotonPeer> _regionServers;
    	private bool _getRegionServer;
    
    	public void Awake()
    	{
    		_regionServers = new List<PhotonPeer>();
    		_peer = new PhotonPeer(this, ConnectionProtocol.Udp);
    		_peer.Connect("127.0.0.1:5055", "BuzzMMOMaster");
    	}
    
    	public void Update()
    	{
    		_peer.Service();
    		//Debug.Log(_peer.PeerState.ToString());
    
    		foreach (var regionServer in _regionServers)
    			regionServer.Service();
    	}
    
    	public void OnApplicationQuit()
    	{
    		_peer.Disconnect();
    
    		foreach (var regionServer in _regionServers)
    			regionServer.Disconnect();
    	}
    
    	public void OnEvent(EventData eventData)
    	{		
    		var regionServers = eventData.Parameters[0].ToString().Split(',');
    		foreach (var server in regionServers)
    		{
    			var regionServer = new PhotonPeer(this, ConnectionProtocol.Udp);
    			regionServer.Connect(server, "BuzzMMORegion");
    			_regionServers.Add(regionServer);
    		}
    	}
    
    	public void DebugReturn(DebugLevel level, string message)
    	{
    	}
    
    	public void OnOperationResponse(OperationResponse operationResponse)
    	{
    	}
    
    	public void OnStatusChanged(StatusCode statusCode)
    	{
    		Debug.Log(string.Format("Status Changed: {0}", statusCode));
    
    		if (statusCode == StatusCode.Connect && !_getRegionServer)
    		{
    			_getRegionServer = true;
    			_peer.OpCustom(1, new Dictionary<byte, object> {{1, "Get RegionServers"}}, false);
    		}
    
    	}
    }

  6. #6
    Join Date
    Jun 2008
    Location
    Iran / Tehran
    Posts
    285
    those for sure helped me, nelson really needs to update these videos for future people who watch these
    thanks
    If you want to learn something, start teaching about it to others, nothing will help you more than that !

  7. #7
    Join Date
    Feb 2014
    Posts
    277
    Interesting point.
    Some might argue that the community has more time to figure out why updates need changes rather than Nelson. The list of Nuget updates alone is staggering.
    I'm still using Photon 3.4.28 so I never had the issues in this post.
    Here's a point - should the community be responsible for finding potential solutions to updates? Perhaps Nelson (who says he reads the forums a bit) then use us as a resource to merging them officially into the project?

    As a matter of interest there is a growing list of things that Nelson COULD go back and fix, but he has clearly stated a few times that he wants to push on and get to writing the game. We've been years getting to this point.

    I've not heard to the contrary, but Jason's health will no doubt effect the future of this project.

  8. #8
    Join Date
    Feb 2015
    Location
    Turkiye
    Posts
    18
    I've just finished the "Intro to TeamCity" video, but for the previous videos i had to deal with some problems time to time but thanks Google and some explanations in 3dbuzz forums i was able to solve them. I dont think Nelson LaQuet can/should redo these videos.(at least until the completion of the full series). I've learnt a lot from here (both from the free lessons and the paid ones) and i don't think there is another place offers trainings like in here 3DBuzz.com. Thanks everyone involved.

  9. #9
    Join Date
    Aug 2010
    Posts
    158
    The community here is always happy to help. Most of us are in the same boat.

    As far as Photon goes, any 3.4.x should work and it is still available on the Photon Download page under other versions. The only caviot here is that you will need to ensure that what ever binaries you are referencing in your project / libs folder match the binaries from the Photon Installation that you are using.

    I think we should update to Photon 4.x as the refactor should be fairly short and would allow us more overhead for changes. They also change the way that servers interact with other servers.

  10. #10
    Join Date
    Jun 2008
    Location
    Iran / Tehran
    Posts
    285
    there is also another change in new photon version, in nelson's video he grabs the dll for unity from the unity sdk pack, but in new sdk pack it would through an error, instead you should use the dll that is packed with the photon sdk itself, the one in the unity sdk is for those who want to right code inside unity not those who want separate solutions for assemblies
    If you want to learn something, start teaching about it to others, nothing will help you more than that !

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •