Unity & Server Communication Lost

Options
Kruga
edited September 2010 in DotNet
I was Hoping not to have to post here. Cause this Question is going to take ages..... :oops:

History of Project :
    Client = Unity 2.6 Project Server = .NET 3.5 Project using Linq for database. Unts = .Net 3.5 and clone .net 2.0 projects that hold enums for operationcode and parametercodes.
I have a unity Client and Server. These use to connect and login fine. But now that I have advanced the code I can't seem to get it to communicate properly. And that is using the setup above. But now I'm trying to get a person to log in, then when that is complete and accepted. The Server will send back a responce passing about 10 varables back. Camera position and rotation. Which is sorted in the database with the client disconnects.

Problem :
Now the server is running, and fires log events to the database.
I start the server no prob...
Start Client Unity project.. no errors not prob.
Shows Connect(ed) in debug.log.
Then I check the database log for the server. And it recieves the login request.
processes it against the database and retrives the logged in player and puts all the player information into a hashtable and send it off.
But then nothing happened on the client side at all. It dose not even call the OperationResult Method(function).
 public void OperationResult(byte opCode, int returnCode, Hashtable returnValues, short invocID)
 {
}

OK this is the hard bit. I'll have to post the server code and the client.

Server Code
 public void OnOperationRequest(OperationRequest request)
        {
            TheGame.Save_debugMessage("Line 39 : Request OnOperationRequest Entered:");
            switch ((OperationCodes)request.OperationCode)
            {
                    
                #region Login
                case OperationCodes.Login:
                    
                    LoginOperation LO = new LoginOperation(request);
                    TheGame.Save_debugMessage("Login Request From Client");
                    TheGame.Save_debugMessage("Login.User = " + LO.User.ToString());
                    TheGame.Save_debugMessage("Login.Password = " + LO.Password.ToString());
                    TheGame.Save_debugMessage("Login.IsValid = " + LO.IsValid.ToString());
                   
                    if (LO.IsValid)
                    {
                        Player_Information GetPlayer = TheGame.LoginUser(LO.User, LO.Password);
                       
                        if (GetPlayer != null)
                        {
                            Dictionary<short, object> PassInData = new Dictionary<short, object>();
                            if (GetPlayer.FirstTimeLoad)
                            {
                                //TODO : Player Must be assign a sector , solosystem and Home Planet.
                                //TODO : Get the Player to Create a Empire of some sort.
                                //TODO : Load Camera positions and everything else needed
                            }
                            else
                            {
                                //DB_Position CameraPosition = TheGame.LoadPostion(GetPlayer.CameraPositionId);
                                //DB_Position CameraRotation = TheGame.LoadPostion(GetPlayer.CameraRotationId);
                                ////TODO : Create Empire table and Retrieve it from the database.
                                //PassInData.Add((byte)ParameterCode.Player_CameraPosition, new float[3] { (float)CameraPosition.x, (float)CameraPosition.y, (float)CameraPosition.z });
                                //PassInData.Add((byte)ParameterCode.Player_CameraRotation, new float[3] { (float)CameraRotation.x, (float)CameraRotation.y, (float)CameraRotation.z });
                                PassInData.Add((byte)ParameterCode.Player_CameraMode, GetPlayer.CorrentMode);
                                //PassInData.Add((byte)ParameterCode.Player_Credits, GetPlayer.Credits);
                                //PassInData.Add((byte)ParameterCode.Player_EmpireName, "New Empire");
                                //PassInData.Add((byte)ParameterCode.Player_UserName, GetPlayer.Name);
                                PassInData.Add((byte)ParameterCode.Player_CurrentZone, GetPlayer.SectorGrid);
                                PassInData.Add((byte)ParameterCode.Player_CurrentSoloSystem, GetPlayer.SoloSystem);
                                PassInData.Add((byte)ParameterCode.Player_PlayerId, GetPlayer.PlayerID);
                                //PassInData.Add((byte)ParameterCode.Server_MOD, TheGame.LoadServerData("MOD"));
                            }

                            var responseGood = new OperationResponse(request, (int)ErrorCode.Ok,
                                "Login Complete ID :" + LO.ID + " Time : " + DateTime.Now.ToShortDateString(),
                                PassInData);
                            
                            TheGame.Save_debugMessage("Responce Sent To Client" + responseGood.ToString());
                            TheGame.Save_debugMessage("Line 85 : response.OperationCode =  " + responseGood.OperationCode.ToString());
                            this.PhotonPeer.SendOperationResponse(responseGood);
                        }
                    }
                    else
                    {

                        //GetPlayer that was returned, was null. So the Password or login might be wrong.
                        var responseBad = new OperationResponse(request, (int)ErrorCode.AccessDenied, "Invalid User name or password| Login :"+LO.User +"| Password :"+LO.Password+"| Message :"+LO.GetErrorMessage());
                        this.PhotonPeer.SendOperationResponse(responseBad);
                    }
                    break;
                #endregion

                #region Reconnect Player After Loading Scene
                case OperationCodes.ReconnectPlayerAfterLoading:
                    ReconnectPlayerAfterLoadingOperation ReconnectPlayerOp = new ReconnectPlayerAfterLoadingOperation(request);
                    if (ReconnectPlayerOp.IsValid)
                    { ......//Blah blah
}

Client Unity Script
public void OperationResult(byte opCode, int returnCode, Hashtable returnValues, short invocID)
        {
            DebugReturn("nPeerReturn() " + opCode + "/" + returnCode+"/"+ returnValues.ToString()+"/"+ invocID.ToString());

            //handle operation returns
            switch (opCode)
            {
                #region Login
                case (byte)OperationCodes.Login:
                    //get the local player's numer from the returnvalues, get the player from the list and colorize it:
                    //int actorNrReturnedForOpJoin = (int)returnValues[(byte)LiteOpKey.ActorNr];#
                    DebugReturn("Return Values Count :" + returnValues.Count.ToString());
                    //if (returnValues != null)
                    //{
                    //    foreach (object item in returnValues.Keys)
                    //    {
                    //        DebugReturn(item.ToString());
                    //    }
                    //}
                    //else
                    //{
                    //    DebugReturn("returnValues == Null");
                    //}
                    if (returnCode == (int)ErrorCode.Ok)
                    {
                        DebugReturn("OperationCodes.Login : | Empire Returned from server :" + returnValues[(byte)ParameterCode.Player_EmpireName].ToString());
                        PostBack LoginPostBack = new PostBack((OperationCodes)opCode, (ErrorCode)returnCode, true);
                        LoginPostBack.ReturnedHashTable = returnValues;
                        PostBackList.Add(LoginPostBack.OperationCode, LoginPostBack);
                        if (OnLogin != null) OnLogin(this, EventArgs.Empty);
                    }
                    else if (returnCode == (int)ErrorCode.AccessDenied)
                    {
                        DebugReturn("OperationCodes.Login : | AccessDenied :" + returnValues[(byte)1].ToString());
                        if (OnLoginFAIL != null) OnLoginFAIL(this, EventArgs.Empty);
                    }
                    break;

I Shortened it because there is lots of code there. But these parts are where the problem seems to be happening. It seem to just loose the response back to the client. Not sure why. I double check the short's and byte's. Rechecked the interface. I recompiled all the enums so that they are exactly the same.

I downloaded teh 30 day trial lic by mistake. So I download the 50 max client one and added it to the win_xp Photon. I'm running windows 7 1500 ram.

I think I've come to that point that I just see the problem now. It might be something really simple.. who knows..

Could My packets be too big? I noticed I have to swap from short to byte as well. Would that be the prob? Even though they're basically the same..

LOGS
Client
nPeerReturn():Connect
Connect(ed)

Database Server LOGS
Id	Message	CreatedTime
2	Server Started-------------------------------------------	2010-09-12 23:58:26.660
3	Line 39 : Request OnOperationRequest Entered:	2010-09-12 23:58:48.087
4	Line 39 : Request OnOperationRequest Entered:	2010-09-12 23:58:48.100
5	Login Request From Client	2010-09-12 23:58:48.213
6	Login.User = LoginUser	2010-09-12 23:58:48.247
7	Login.Password = LoginPassword	2010-09-12 23:58:48.253
8	Login.IsValid = True	2010-09-12 23:58:48.263
9	Method : LoginUser : GameControler.cs	2010-09-12 23:58:48.297
10	Method : DataModel.PlayerInformation_Login = true : GameControler.cs	2010-09-12 23:58:48.993
11	Responce Sent To ClientPhoton.SocketServer.OperationResponse	2010-09-12 23:58:49.220
12	Line 85 : response.OperationCode =  1	2010-09-12 23:58:49.253

Finish of my Book / Question... :D

As you can see it's 11:58 at night. so I'll calling it a night.
Thanks Ahead of time
Kruga NZ:

Comments

  • Boris
    Options
    probably not related, but on win7 32 bit you should use the photon in bin_Win32, not the xp version.
  • Boris
    Options
    is your code based on any specific sample? MMO Demo? Lite?
    If it is the MMO Demo you might have implemented the operation response handler for Login (OperationResult) in the wrong game state?
  • I know about the win_xp thing. I just haven't changed it over. It's worked fine in old build. So I figured, when the sever needs better performance I'll switch it over to the correct one.

    My code was sort of base on the MMO build. to the wrong state.. :/
    Do you mean?

    in the server : OperationCode.Login == (byte) 1
    and in the Client : OperationCode.Login == (byte) 0

    or
    public enum OperationCode : short
    vs
    public enum OperationCode : Byte

    This shouldn't make a difference. But I'll ask. cast from short to byte and byte to short from the hashtable shouldn't make a difference aye? I'd think it would be fine.
  • Boris
    Options
    on the client side there is a different class for every state (namespace Photon.MmoDemo.Client.GameStateStrategies)
    - Disconnected
    - WaitingForConnect
    - Connected
    - WorldEntered
    Which class did you extend with the login response handler?