Пример #1
0
        public void Dispose()
        {
            Log.Entered();

            // Close resources that persist outside of sessions
            Profiler.Close();
            Logger.Close();
        }
Пример #2
0
        /// <summary>
        /// Returns a new component instance if it should be created, else null.
        /// </summary>
        public bool TryCreateInstance(RunLocation runningOn, object attachedTo, out ComponentInstanceDescription result)
        {
            Log.Entered();

            result = null;
            if (!ShouldRunOn(runningOn))
            {
                return(false);
            }

            try { if (!InvokeConditionFunc(attachedTo))
                  {
                      return(false);
                  }
            }
            catch (Exception e)
            {
                Logger.Log($"Error invoking condition func from {this}: {e}", Severity.Level.ERROR);
                if (Debug)
                {
                    Notification.Notify($"Error invoking condition func for {ComponentClass.FullName}.", 10000, Severity.Level.ERROR);
                }
                return(false);
            }

            object instance;
            List <ComponentEventAction> actions;

            try
            {
                instance = CreateInstance(attachedTo);
                actions  = EventMethods.Where(x => x.ShouldRunOn(runningOn)).Select(x => x.ToEventAction(instance)).ToList();
            }
            catch (Exception e)
            {
                Logger.Log($"Error instantiating component {this}: {e}", Severity.Level.ERROR);
                if (Debug)
                {
                    Notification.Notify($"Error instantiating {ComponentClass.FullName}.", 10000, Severity.Level.ERROR);
                }
                return(false);
            }

            Log.Debug("Created instance of " + ComponentClass);

            result = new ComponentInstanceDescription()
            {
                ComponentClass    = ComponentClass,
                ComponentInstance = instance,
                EventActions      = actions,
            };
            return(true);
        }
Пример #3
0
        static byte[] FormatMessage(BitStream payload, ushort domainId, ushort typeId, ulong senderId)
        {
            Log.Entered();
            BitStream stream = new BitStream();

            stream.ResetWrite();
            HandlerRegistrar.SerializeHeaders(ref stream, ref domainId, ref typeId, ref senderId);
            Log.Trace($"Adding payload of length {payload.ByteLength} to formatted message of length {stream.ByteLength}");
            payload.ResetRead();
            stream.WriteBitStream(payload);
            Log.Trace($"Formatted message final length {stream.ByteLength}");
            return(stream.ToBytes());
        }
Пример #4
0
 void RegisterMessageHandlers()
 {
     Log.Entered();
     HandlerRegistrar.Register(Session.MessageDomain, (ushort)Messages.MessageType.LoginRequest, HandleLoginRequest);
 }
Пример #5
0
 public MySession() : base()
 {
     Log.Entered();
     ComponentSession.Open();
 }
Пример #6
0
 private void SessionClosed()
 {
     Log.Entered();
     //LastUpdateAt = ClosedAt = Stopwatch.GetTimestamp();
     //WorldClosed = true;
 }
Пример #7
0
 /// <summary>
 /// Initialized by ComponentSession
 /// </summary>
 public HandlerRegistrar()
 {
     Log.Entered();
     MyAPIGateway.Multiplayer.RegisterMessageHandler(HandlerId, HandleMessage);
     Static = this;
 }
Пример #8
0
 public void Dispose()
 {
     Log.Entered();
 }