Esempio n. 1
0
        // actor exit
        private void ActorExit(Region region, long id)
        {
            /* this lock is not necessary */            //lock( _region_actor )
            {
                // find actor
                // if the actor is found, only set null src region.
                // because before sending the message, the same actor may change region several times,
                // the first src regin should be the truely region that the actor exits from.
                ActorUtils.RegionActorPair rap = null;
                if (_region_actor.TryGetValue(id, out rap))
                {
                    // set old region
                    if (null == rap.src)
                    {
                        rap.src = region;
                    }
                }
                else
                {
                    rap       = new ActorUtils.RegionActorPair();
                    rap.actor = ActorUtils.CreateActor(id, null);
                    rap.src   = region;

                    _region_actor.Add(id, rap);
                }
            }
        }
Esempio n. 2
0
        // own actor.
        // update the actor
        // and watch operations on the actor
        private void ActorEnter(Region region, long id, Dictionary <int, ByteString> properties)
        {
            /* this lock is not necessary */            //lock( _region_actor )
            {
                // find actor
                // if actor is found, update its properties and replace the dest region.
                // because before sending the message, the same actor may change region several times,
                // the latest dest region will be the true that the actor truely enters.
                ActorUtils.RegionActorPair rap = null;
                if (_region_actor.TryGetValue(id, out rap))
                {
                    // copy properties
                    ActorUtils.CopyProperties(properties, rap.actor.Ptypes, rap.actor.Pdatas);

                    // set new dest
                    // replace the region was set
                    rap.dest = region;
                }
                // else insert the actor.
                else
                {
                    rap       = new ActorUtils.RegionActorPair();
                    rap.actor = ActorUtils.CreateActor(id, properties);
                    rap.dest  = region;

                    _region_actor.Add(id, rap);
                }
            }
        }
Esempio n. 3
0
 // update properties
 public void ActorUpdate(Region region, long id, Dictionary <int, ByteString> properties)
 {
     /* this lock is not necessary */            //lock( _message )
     {
         Actor a = ActorUtils.FindActor(id, _message.UpdateActors);
         if (null == a)
         {
             a = ActorUtils.CreateActor(id, properties);
             _message.UpdateActors.Add(a);
         }
         else
         {
             ActorUtils.CopyProperties(properties, a.Ptypes, a.Pdatas);
         }
     }
 }
Esempio n. 4
0
        public void MessageProcess(GateToPlayer msg)
        {
            ConsoleOutput.Trace("ActorManager: MessageProcess" + " P" + msg.ResponseProperty.Count + " C" + msg.ResponseConfig.Count);
            // process operations
            foreach (Operation operation in msg.Operations)
            {
                _actors_listener.ialOperate(operation.Src, operation.Dest, operation.Ptype, operation.Data);
            }

            // process responses of property
            {
                Dictionary <long, Dictionary <int, ByteString> > properties
                    = new Dictionary <long, Dictionary <int, ByteString> >();
                foreach (IdPtypeData property in msg.ResponseProperty)
                {
                    ActorUtils.InsertIdTypeData
                        (property.Id, property.Ptype, property.Data, properties);
                }

                /* this lock is not necessary */                //lock( _actors_listener )
                {
                    foreach (KeyValuePair <long, Dictionary <int, ByteString> > i in properties)
                    {
                        _actors_listener.ialResponseProperties(i.Key, i.Value);
                    }
                }
            }

            // process responses of config
            {
                Dictionary <long, Dictionary <int, ByteString> > configs
                    = new Dictionary <long, Dictionary <int, ByteString> >();
                foreach (IdCtypeData config in msg.ResponseConfig)
                {
                    ActorUtils.InsertIdTypeData
                        (config.Id, config.Ctype, config.Data, configs);
                }

                /* this lock is not necessary */                //lock( _actors_listener )
                {
                    foreach (KeyValuePair <long, Dictionary <int, ByteString> > i in configs)
                    {
                        _actors_listener.ialResponseConfigs(i.Key, i.Value);
                    }
                }
            }
        }