[Solved] Hello World 2 Problems (Photon Vs 3)

nventimiglia
edited September 2011 in DotNet
Hey, going through the Hello World2 tutorial (photon server vs 3) and have some problems.


1) Dictionary. I have no non generic dictionary class (such as used in the docs).... I am able to use Dictionary<byte, object> without problem however. Might want to update the tutorial.

2) Duplicate enums. Why are the enum's from the Light assembly duplicated locally ?

3) (My Real Problem) The OnEvent(EventData eventData) method is not reading my "101 event" Im not sure how to debug this. No exceptions are thrown. Event 255 is read successfully. Here is my code for the OnEvent and OnOperationResponse.
   public void OnEvent(EventData eventData)
        {
            Console.WriteLine("\n---OnEvent: " +
                (EvCodeEnum)eventData.Code +
                "(" + eventData.Code + ")");

            switch (eventData.Code)
            {
                case 101:
                    var sourceActorNr = (int)eventData.Parameters&#91;LiteEventKey.ActorNr&#93;;
                    var evData = (Hashtable)eventData.Parameters&#91;LiteEventKey.Data&#93;;
                    Console.WriteLine(" -&gt;Player" + sourceActorNr + " say's: " + evData&#91;(byte)1&#93;);
                    break;
            }
        }

        public void OnOperationResponse(OperationResponse operationResponse)
        {
            if (operationResponse.ReturnCode == 0)
                Console.WriteLine("\n---OnOperationResponse: OK - " +
                    (OpCodeEnum)operationResponse.OperationCode + "(" + operationResponse.OperationCode + ")");
            else
            {
                Console.WriteLine(
                    "\n---OnOperationResponse: NOK - " +
                    (OpCodeEnum)operationResponse.OperationCode + "(" +
                    operationResponse.OperationCode + ")\n -&gt;ReturnCode=" +
                    operationResponse.ReturnCode + " DebugMessage=" +
                    operationResponse.DebugMessage);
                return;
            }

            switch (operationResponse.OperationCode)
            {
                // handle join operation
                case LiteOpCode.Join:
                    // server set asscending id
                    var myActorNr = (int)operationResponse.Parameters&#91;LiteOpKey.ActorNr&#93;;
                    Console.WriteLine(" -&gt;My PlayerNr (or ActorNr) is:" + myActorNr);

                    Console.WriteLine("Calling OpRaiseEvent ...");

                    //OpRaiseEvent failed. This is because the parameter Data is expected to be a hashtable
                    //var opParams = new Dictionary&lt;byte, object&gt;();
                    //opParams&#91;LiteOpKey.Code&#93; = (byte)101;
                    //opParams&#91;LiteOpKey.Data&#93; = "Hello World!";

                    var opParams = new Dictionary&lt;byte, object&gt;();
                    opParams&#91;LiteOpKey.Code&#93; = (byte)101;

                    var evData = new Hashtable();
                    evData&#91;(byte)1&#93; = "Hello World!";
                    opParams&#91;LiteOpKey.Data&#93; = evData;

                    peer.OpCustom(LiteOpCode.RaiseEvent, opParams, true);
                    break;
            }
        }

Comments

  • are you trying to send the event to yourself or to someone else? Lite won't send events back to yourself, just to other players.
  • Thanks for the quick reply.

    You called it. I didnt notice that the tutorial was showing 2 clients running.

    The console works.