Sending a list of infortion/items

Options
crzyone9584
edited January 2012 in Photon Server
I have a list of items that the server needs to send to the client. How would i go about sending an entire List<> of data? I've been looking through the MMO and Lite demo source and really haven't found a way to do it it unless I've missed something.

Comments

  • would something like this work?
    var response = new OperationResponse((byte)OperationCode.SendItems, New Dictionary&lt;byte, List&lt;armor&gt;
    {
    // add the list to the data code here
    });
    
  • xzlxt720
    Options
    Why not try to do it
  • Tobias
    Options
    Armor is not immediately supported as data type, so it can't be sent, unless you register de/serialization methods for this type first. I will ask a colleague to supply the method names for this.
    Also, a List is not directly supported but you can simply convert the list into an array and send that.
  • Okay, I'll look the documentation on how to send an array after converting the list.

    @xzlxt720 - The reason I didn't want to try it first is because I just finally fixed all the errors on my server and did not want to create even more errors.

    I've been messing around and so far came up with this before the reply.
    var acc = new OperationResponse((byte)OperationCode.EditorList, new Dictionary&lt;byte, object&gt;
                        {
                            {(byte)DataCode.Editor, editor},
                            {(byte)DataCode.EditorList, Lists.accessory}
                        });
                        peer.SendOperationResponse(acc, parameters);
    

    Only thing is I'm having trouble figuring out how to accept the list on the client side and i'm not sure if all the data is getting sent from the list.
  • xzlxt720
    Options
    var dict_head = new Dictionary&lt;byte, object&gt;
                        {
                              {(byte)DataCode.Attack, 100},
                              {(byte)DataCode.Defence, 100}
                        }
    
    var dict_hand = new Dictionary&lt;byte, object&gt;
                        {
                              {(byte)DataCode.Attack, 100},
                              {(byte)DataCode.Defence, 100},
                              {(byte)DataCode.Other, 100}
                        }
    
    var dict_armour = new Dictionary&lt;byte, object&gt;
                        {
                             {(byte)DataCode.Armour_Head, dict_head},
                             {(byte)DataCode.Armour_Hand, dict_hand}
                        }
    
    var armours.Add(dict_armour)
    
    var dict = new Dictionary&lt;byte, object&gt;
                        {
                             {(byte)DataCode.Armour, armours.ToArray()}
                        }
    var acc = new OperationResponse((byte)OperationCode.EditorList, dict);
                        peer.SendOperationResponse(acc, parameters);
    

    maybe it looks like this ,does it right?
  • Okay i understand to send them as an array but how would I add them to the list on via client side?
  • xzlxt720
    Options
    Is it the same as you do on the server side?
  • Tobias
    Options
    crzyone9584: "how would I add them to the list on via client side"?! I don't understand where you're stuck.