Skip to content

Commit 6738188

Browse files
committed
Fix #62 Don't send messages from the server back to it as client.
1 parent 24b881e commit 6738188

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Solution/TypeCobol.LanguageServer.Robot.Common/Controller/LanguageServerRobotController.cs

+20-3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ public string ServerOptions
7474
get; set;
7575
}
7676

77+
/// <summary>
78+
/// For Inversion of control mode.
79+
/// </summary>
80+
public bool InversionOfControl
81+
{
82+
get;
83+
internal set;
84+
}
85+
7786
/// <summary>
7887
/// Timeoout to wait for the Monitor Application to establish the connection : 30s == 10000ms
7988
/// </summary>
@@ -778,7 +787,11 @@ public virtual void FromServer(string message)
778787
else
779788
{
780789
ServerConnection.FromServer(message);
781-
ClientConnection.SendMessage(message);
790+
//In ioc Mode don't resent to the Server any message as the server is also the client.
791+
if (!InversionOfControl)
792+
{
793+
ClientConnection.SendMessage(message);
794+
}
782795
}
783796
}
784797

@@ -790,6 +803,7 @@ public virtual void FromServer(string message)
790803
/// <param name="serverPath">The Server's path</param>
791804
/// <param name="serverOptions">The Server's options</param>
792805
/// <param name="scriptRepositoryPath">The script repository path</param>
806+
/// <param name="promptReplay">Display a wait message before starting replay</param>
793807
/// <returns>0 if no error -1 otherwise.</returns>
794808
public static int ReplayScript(string script_path, Script script, string serverPath, string serverOptions, string scriptRepositoryPath, bool bStopAtFirstError, bool promptReplay)
795809
{
@@ -814,13 +828,16 @@ public static int ReplayScript(string script_path, Script script, string serverP
814828
/// <param name="script_path">The path of the script to replay</param>
815829
/// <param name="script">The script model to replay</param>
816830
/// <param name="scriptRepositoryPath">The script repository path</param>
831+
/// <param name="inversionOfControl">Inform about an inversion of control mode</param>
832+
/// <param name="promptReplay">Display a wait message before starting replay</param>
817833
/// <returns>0 if no error -1 otherwise.</returns>
818-
public static int DumpScript(string script_path, Script script, string scriptRepositoryPath, bool bStopAtFirstError)
834+
public static int DumpScript(string script_path, Script script, string scriptRepositoryPath, bool bStopAtFirstError, bool inversionOfControl, bool promptReplay)
819835
{
820836
var server = new ServerRobotConnectionController(new MessageConnection());
821837
var robot = new LanguageServerRobotController(script_path, script, server, bStopAtFirstError, scriptRepositoryPath);
838+
robot.InversionOfControl = inversionOfControl;
822839
robot.PropagateConnectionLogs();
823-
if (!robot.Start(false))
840+
if (!robot.Start(promptReplay))
824841
{
825842
return -1;
826843
}

Solution/TypeCobol.LanguageServerRobot/LanguageServerRobot.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,9 @@ private static int ReplayScript(string script_path, Script script, bool bStopAtF
464464
//Check if we have an workspace/didChangeConfiguration notification to apply
465465
if (ConfigNotifyOption != null)
466466
script.did_change_configuation = ConfigNotifyOption;
467+
467468
if (InversionOfControl)
468-
return LanguageServerRobotController.DumpScript(script_path, script, ScriptRepositoryPath, bStopAtFirstError);
469+
return LanguageServerRobotController.DumpScript(script_path, script, ScriptRepositoryPath, bStopAtFirstError, true, promptReplay);
469470
else
470471
return LanguageServerRobotController.ReplayScript(script_path, script, ServerPath, ServerOptions, ScriptRepositoryPath, bStopAtFirstError, promptReplay);
471472
}

0 commit comments

Comments
 (0)