Class for constants. These values are for events defined by Photon Loadbalancing. Pun uses these constants internally.
They start at 255 and go DOWN. Your own in-game events can start at 0.
예제 #1
0
        private void ReceiveEvent(EventCode eventCode, Func<EventData, bool> checkAction)
        {
            try
            {
                this.peer.Service();

                lock (this.peerListener.EventList)
                {
                    while (this.peerListener.EventList.Count > 0)
                    {
                        var ev = this.peerListener.EventList[0];
                        this.peerListener.EventList.RemoveAt(0);
                        if ((byte)ev.Code == (byte)eventCode && checkAction(ev))
                        {
                            this.receivedEvent = ev;
                            this.OnEventReceived();
                            this.resetEvent.Set();
                            return;
                        }
                    }
                }

                if (this.stopWatch.ElapsedMilliseconds > Settings.WaitTimeMultiOp)
                {
                    Interlocked.Increment(ref exceptions);
                    log.ErrorFormat("client {0} did not receive event {2} in time. {1}ms waited", this.Username, this.stopWatch.ElapsedMilliseconds, eventCode);
                }
                else
                {
                    this.fiber.Schedule(() => this.ReceiveEvent(eventCode, checkAction), 10);
                }
            }
            catch (Exception e)
            {
                this.HandleException(e);
            }
        }
예제 #2
0
 public void BeginReceiveEvent(EventCode eventCode, Func<EventData, bool> checkAction, int delay)
 {
     this.stopWatch.Reset();
     this.fiber.Schedule(
         () =>
             {
                 this.stopWatch.Start();
                 this.ReceiveEvent(eventCode, checkAction);
             },
         delay);
 }
예제 #3
0
 /// <summary>
 ///   The begin receive event.
 /// </summary>
 /// <param name = "client">
 ///   The client.
 /// </param>
 /// <param name = "eventCode">
 ///   The event code.
 /// </param>
 /// <param name = "delay">
 ///   The delay.
 /// </param>
 private static void BeginReceiveEvent(Client client, EventCode eventCode, int delay)
 {
     client.BeginReceiveEvent(eventCode, d => true, delay);
 }
예제 #4
0
 /// <summary>
 ///   The end receive event.
 /// </summary>
 /// <param name = "client">
 ///   The client.
 /// </param>
 /// <param name = "eventCode">
 ///   The event EventCode.
 /// </param>
 /// <returns>
 ///   the received event
 /// </returns>
 private static EventData EndReceiveEvent(Client client, EventCode eventCode)
 {
     EventData data;
     Assert.IsTrue(client.EndReceiveEvent(Settings.WaitTime, out data), "Event not received");
     Assert.AreEqual(eventCode, (EventCode)data.Code);
     return data;
 }
예제 #5
0
 /// <summary>
 ///   The begin receive event.
 /// </summary>
 /// <param name = "client">
 ///   The client.
 /// </param>
 /// <param name = "eventCode">
 ///   The event code.
 /// </param>
 /// <param name = "checkAction">
 ///   The check action.
 /// </param>
 /// <param name = "delay">
 ///   The delay.
 /// </param>
 private static void BeginReceiveEvent(Client client, EventCode eventCode, Func<EventData, bool> checkAction, int delay)
 {
     client.BeginReceiveEvent(eventCode, checkAction, delay);
 }