public void Dispose() { Log.Entered(); // Close resources that persist outside of sessions Profiler.Close(); Logger.Close(); }
/// <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); }
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()); }
void RegisterMessageHandlers() { Log.Entered(); HandlerRegistrar.Register(Session.MessageDomain, (ushort)Messages.MessageType.LoginRequest, HandleLoginRequest); }
public MySession() : base() { Log.Entered(); ComponentSession.Open(); }
private void SessionClosed() { Log.Entered(); //LastUpdateAt = ClosedAt = Stopwatch.GetTimestamp(); //WorldClosed = true; }
/// <summary> /// Initialized by ComponentSession /// </summary> public HandlerRegistrar() { Log.Entered(); MyAPIGateway.Multiplayer.RegisterMessageHandler(HandlerId, HandleMessage); Static = this; }
public void Dispose() { Log.Entered(); }