private bool HostWriteResult( ReturnCode code, Result result, int errorLine, bool newLine ) { if (_interpreter == null) { c_Error(Utility.FormatResult( code, result, errorLine), newLine); return(false); } IDebugHost host = _interpreter.Host; if (host == null) { c_Error(Utility.FormatResult( code, result, errorLine), newLine); return(false); } return(host.WriteResult( code, result, errorLine, newLine)); }
public ServerCommandHost(IServer commandHost) { Guard.That(commandHost, "Command host must not be null").IsNotNull(); this.commandHost = commandHost; executioners = new Stack <ICommandExecutioner>(); commandTable = new Dictionary <string, CommandInfo>(); EchoToAll = new DebugHost(); EchoToAll.RegisterAppender(new ActionAppender(commandHost.NotifyAll)); //Setup echo to respond only to the defined connection Echo = (msg, connection) => { var om = commandHost.CreateMessage(); var serverNotification = new Notification(msg, NotificationType.Message); MessageSerializer.Encode(serverNotification, ref om); GemNetworkDebugger.Append.Info(msg); commandHost.SendOnlyTo(om, connection); }; RegisterHelpComand(); RegisterSetPasswordCommand(); RegisterEchoCommand(); RegisterKickCommand(); RegisterViewClientsCommand(); //the default password Password = "******"; }
/////////////////////////////////////////////////////////////////////// #region Asynchronous Methods private void AsyncExit( object state ) { if (Interlocked.Increment(ref exiting) == 1) { if (Interlocked.Increment(ref exited) == 1) { ReturnCode code; Result error = null; if (interpreter != null) { IDebugHost debugHost = interpreter.Host; if (debugHost != null) { #if NOTIFY || NOTIFY_OBJECT // // NOTE: Globally mask off the test plugin // notification flags because at this point // we do not want any kind of re-entrancy, // asynchronous or otherwise. // interpreter.GlobalNotifyTypes &= ~Utility.GetNotifyTypes(typeof(_Plugins.TestForm)); interpreter.GlobalNotifyFlags &= ~Utility.GetNotifyFlags(typeof(_Plugins.TestForm)); #endif // // NOTE: Cancel anything being evaluated in the // interpreter. // code = Engine.CancelEvaluate( interpreter, "test form exit", CancelFlags.UnwindAndNotify, ref error); // // NOTE: Mark the interpreter as "exited". // interpreter.Exit = true; // // NOTE: Break out of any attempt to read a line of // input from the user if the interpreter has // an interactive loop going. // if ((code == ReturnCode.Ok) && Test.HaveInteractiveLoop()) { code = debugHost.Cancel(false, ref error); } // // NOTE: If we failed for some reason, I suppose // we want to be able to retry later. // if (code == ReturnCode.Ok) { AsyncDispose(); } #if NOTIFY || NOTIFY_OBJECT else { interpreter.GlobalNotifyFlags |= Utility.GetNotifyFlags(typeof(_Plugins.TestForm)); interpreter.GlobalNotifyTypes |= Utility.GetNotifyTypes(typeof(_Plugins.TestForm)); } #endif } else { error = "interpreter host not available"; code = ReturnCode.Error; } } else { error = "invalid interpreter"; code = ReturnCode.Error; } // // NOTE: If we did not succeed, at least attempt to provide // hints as to why. // if (code != ReturnCode.Ok) { // // NOTE: Update the status with our async failure. // AsyncAppendStatusText(Utility.FormatResult(code, error), true); // // NOTE: We did not actually manage to exit, reset // the exited indicator now. // Interlocked.Decrement(ref exited); } } else { // // NOTE: We do not want the exited indicator to have a // value higher than one (i.e. it is a logical // boolean); therefore, decrement it now. // Interlocked.Decrement(ref exited); } } Interlocked.Decrement(ref exiting); }
public HostExecutionServices(ICompositionHost host) { _debugHost = host.GetSharedExportedValue <IDebugHost>(); }