Esempio n. 1
0
 private void HandleSubscriptionRequests()
 {
     if (this.m_queuedSubscriptions.Count > 0)
     {
         long elapsedMilliseconds = this.m_stopWatch.ElapsedMilliseconds;
         this.m_presenceSubscriptionBalance  = Math.Min((float)0f, (float)(this.m_presenceSubscriptionBalance + ((elapsedMilliseconds - this.m_lastPresenceSubscriptionSent) * 0.003333333f)));
         this.m_lastPresenceSubscriptionSent = elapsedMilliseconds;
         List <EntityId> list = new List <EntityId>();
         foreach (EntityId id in this.m_queuedSubscriptions)
         {
             if ((this.m_presenceSubscriptionBalance - 1f) < -100f)
             {
                 break;
             }
             PresenceRefCountObject obj2    = this.m_presenceSubscriptions[id];
             SubscribeRequest       message = new SubscribeRequest();
             message.SetObjectId(ChannelAPI.GetNextObjectId());
             message.SetEntityId(id);
             obj2.objectId = message.ObjectId;
             base.m_battleNet.Channel.AddActiveChannel(message.ObjectId, new ChannelAPI.ChannelReferenceObject(id, ChannelAPI.ChannelType.PRESENCE_CHANNEL));
             base.m_rpcConnection.QueueRequest(this.m_presenceService.Id, 1, message, new RPCContextDelegate(this.PresenceSubscribeCallback), 0);
             this.m_presenceSubscriptionBalance--;
             list.Add(id);
         }
         foreach (EntityId id2 in list)
         {
             this.m_queuedSubscriptions.Remove(id2);
         }
     }
 }
Esempio n. 2
0
 public void PresenceSubscribe(EntityId entityId)
 {
     if (this.m_presenceSubscriptions.ContainsKey(entityId))
     {
         PresenceRefCountObject local1 = this.m_presenceSubscriptions[entityId];
         local1.refCount++;
     }
     else
     {
         PresenceRefCountObject obj2 = new PresenceRefCountObject {
             objectId = 0L,
             refCount = 1
         };
         this.m_presenceSubscriptions.Add(entityId, obj2);
         this.m_queuedSubscriptions.Add(entityId);
         this.HandleSubscriptionRequests();
     }
 }
Esempio n. 3
0
 public void PresenceUnsubscribe(EntityId entityId)
 {
     if (this.m_presenceSubscriptions.ContainsKey(entityId))
     {
         PresenceRefCountObject local1 = this.m_presenceSubscriptions[entityId];
         local1.refCount--;
         if (this.m_presenceSubscriptions[entityId].refCount <= 0)
         {
             if (this.m_queuedSubscriptions.Contains(entityId))
             {
                 this.m_queuedSubscriptions.Remove(entityId);
             }
             else
             {
                 PresenceUnsubscribeContext context = new PresenceUnsubscribeContext(base.m_battleNet, this.m_presenceSubscriptions[entityId].objectId);
                 UnsubscribeRequest         message = new UnsubscribeRequest();
                 message.SetEntityId(entityId);
                 base.m_rpcConnection.QueueRequest(this.m_presenceService.Id, 2, message, new RPCContextDelegate(context.PresenceUnsubscribeCallback), 0);
                 this.m_presenceSubscriptions.Remove(entityId);
             }
         }
     }
 }