OperationResponse + Array

edited August 2011 in Photon Server

First I must say my english is not so good :(. However, I absolutely need help, please.

So I will send an array from server to client, and processed there, but I get there only the value "null". I have given you something to Pastebin.com uploaded http://pastebin.com/TkVRFehu.

It would be nice if you can help!

With best regards from Germany


  • object arrays are not supported. You have to use a more specific datatype, like byte etc.

    EDIT: you can find a list the available data types here: http://developer.exitgames.com/photoncl ... ryprotocol
  • Well, object arrays WILL be supported by Photon 3. Current downloads don't do this yet.
  • My question then is, should I convert my string array into byte array and dan back or what you think:)?

    Thank you:)
  • Just checked your code. I was misled by Boris' response.
    You are using: string[][] array = new string[500][];
    Thats a 2-dimensional array of strings. I think in the current protocol this is not supported either. 1-dimensional ones are working fine.

    It could be an awful lot of data to send, if you send 500 arrays of array with string in those. This is worth improving! Even if those are empty, they will be sent (empty). It looks like you send some positions. Integer is a better format for those.

    Then: I don't "get" your code: Line 45 looks like a guaranteed bug, as it "randomly" re-sets one of the values.
    You could use a int[] per "id" and use the id in the event's content as key (key = id, value = int[])...
  • I tried it with one dimensional, I still get the value Null :(

    the only thing I do wrong?
    case 112: // MYSQL Test
                        string[] arras = new string[10];
                        arras[1] = "1";
                        arras[2] = "1";
                        arras[3] = "3";
                        Read = new OperationResponse(operationRequest, 0, "posX", new Dictionary<Int16, Object> { { 101, arras } });

    public string[] UserArray = new string[10];
    	public string[] UUserArray = new string[10];
     public void OperationResult(byte opCode, int returnCode, System.Collections.Hashtable returnValues, short invocID)
    		UUserArray = (string[])returnValues[(byte)101];
    		UserArray = UUserArray;
  • Ok, this time, I don't the an issue with the code.
    Which server and client version are you using (the platform-name and numbers in the SDK zip names)?
  • So I took advantage of
    Photon (it's clear) x64bit to Windows 7. The version of the website is the Alktuelle:
    for the client I used Unity3D the Current website.

    In the client I have the following files: PhotonUnity3D
    And for the server: ExitGamesLibs, Photon.SocketServer, photo host runtime interfaces

  • I will try to have a look.

    I assume you cut the client-code which checks for the matching operation code just to make this copy short?? On the client side, you get more responses than just the 112, where you now add the gamer array. You have to switch with the opCode, client side. Only response to op 112 will contain your array. Any else fails with null-ref.

    Please verify for me that you're matching the opcode on the client.
    (I would have asked this before but didn't notice it before.)
  • I've even been tested a little, and the fheler is up to the server and the array, but let's briefly so it has a "OpCustom" function must be between the client and the server to bring abstürtz or community that the engine no longer works, because I have an update in OpCustom comes inside and after a few seconds for it crashes, it appears this is not to be Initialsirt.
  • Also das versteh ich nicht mehr. Lass uns auf Deutsch schreiben...
    Beschreibst du mir deinen letzten Post nochmal?
  • Tut mir leid :(!
    Ich habe schon etwas weitergetestet und schaf es einfach nicht mit den Arrays.
    Kennen sie ein beispiel den beim CLienten kommt immer nur Null an, auch wenn ich Hashtable nutzte!

    Mfg :)!
  • Sorry. Ich hab es heut wieder nicht geschafft das zu testen. Ich bin sicher es geht, aber irgendeine Kleinigkeit läuft schief.
    Wenn du deine Operation aufrufst und das Ergebnis (mit demselben OpCode) bekommst, kannst du den Inhalt des Ergebnisses mal loggen. Die SupportClass hat eine HashtableToString(ht) Funktion dafür. Es würde mir helfen, wenn ich das Ergebnis kenne.

    PS: morgen ist unsere Sommerfeier. Ich glaube bis DO wird das noch dauern.
  • Now I had the time to test this. It's working for me.
    An error in my implementation was, that I tried to get the string[] by: returnValues[101]. C# is a bit picky here: It sees by 101 as integer. The one in the returnValues is byte. It won't be equal! So use: returnValues[(byte)101] to get the content. Then it's working fine.

    I used:
    Photon-DotNet_v6-4-3_SDK.zip (which is about the same as Photon-Unity3D_v6-4-3_SDK.zip)

    My code:
    Realtime Demo Client Form1.cs
            private void OnKeyPress(object sender, KeyEventArgs e)
                if (this.tabPage1.Visible)
                    // ignore in-game key-reactions while in settings tab
                switch (e.KeyCode)
                    case Keys.T:
                        Console.Out.WriteLine("T : Test Op 105 - StringArray");
                        this.GameInstance.peer.OpCustom(105, new Hashtable(0), true);
    Realtime Demo Client. Game.cs
            public void OperationResult(byte opCode, int returnCode, Hashtable returnValues, short invocID)
                if (opCode != (byte)LiteOpCode.RaiseEvent)
                    this.DebugReturn("OperationResult() " + opCode + "/" + returnCode + " = " + SupportClass.HashtableToString(returnValues));
                if (opCode == (byte)105)
                    string[] array = returnValues[(byte)101] as string[];
                    this.DebugReturn("Array content: " + String.Join(", ", array));
    Server. OperationRequestDispatcher.cs (not the best place for this but for testing's sake!)
            public virtual bool DispatchOperationRequest(LitePeer peer, OperationRequest operationRequest)
                switch ((OperationCodes)operationRequest.OperationCode)
                    case OperationCodes.StringArray:  // being 105
                        OperationResponse response = new OperationResponse(
                            new Dictionary<short, object>() { { 101, new string[] { "a string", "b string" } } });
                        //response.Params[(byte)10] = new string[] { "a string", "b string" };
                        return true;

    I hope this helps.