@@ -8,7 +8,7 @@ namespace Microsoft.AspNet.NodeServices {
88 * Class responsible for launching the Node child process, determining when it is ready to accept invocations,
99 * and finally killing it when the parent process exits. Also it restarts the child process if it dies.
1010 */
11- internal abstract class OutOfProcessNodeRunner : NodeHost {
11+ public abstract class OutOfProcessNodeInstance : INodeServices {
1212 private object _childProcessLauncherLock ;
1313 private bool disposed ;
1414 private StringAsTempFile _entryPointScript ;
@@ -18,19 +18,33 @@ internal abstract class OutOfProcessNodeRunner : NodeHost {
1818
1919 protected Process NodeProcess {
2020 get {
21- // This is only exposed to support the UnreliableStreamNodeHost , which is just to verify that
21+ // This is only exposed to support the unreliable OutOfProcessNodeRunner , which is just to verify that
2222 // other hosting/transport mechanisms are possible. This shouldn't really be exposed.
2323 return this . _nodeProcess ;
2424 }
2525 }
2626
27- public OutOfProcessNodeRunner ( string entryPointScript , string commandLineArguments = null )
27+ public OutOfProcessNodeInstance ( string entryPointScript , string commandLineArguments = null )
2828 {
2929 this . _childProcessLauncherLock = new object ( ) ;
3030 this . _entryPointScript = new StringAsTempFile ( entryPointScript ) ;
3131 this . _commandLineArguments = commandLineArguments ?? string . Empty ;
3232 }
3333
34+ public abstract Task < string > Invoke ( NodeInvocationInfo invocationInfo ) ;
35+
36+ public Task < string > Invoke ( string moduleName , params object [ ] args ) {
37+ return this . InvokeExport ( moduleName , null , args ) ;
38+ }
39+
40+ public async Task < string > InvokeExport ( string moduleName , string exportedFunctionName , params object [ ] args ) {
41+ return await this . Invoke ( new NodeInvocationInfo {
42+ ModuleName = moduleName ,
43+ ExportedFunctionName = exportedFunctionName ,
44+ Args = args
45+ } ) ;
46+ }
47+
3448 protected async Task EnsureReady ( ) {
3549 lock ( this . _childProcessLauncherLock ) {
3650 if ( this . _nodeProcess == null || this . _nodeProcess . HasExited ) {
@@ -104,8 +118,8 @@ protected virtual void OnOutputDataReceived(string outputData) {
104118 protected virtual void OnErrorDataReceived ( string errorData ) {
105119 Console . WriteLine ( "[Node] " + errorData ) ;
106120 }
107-
108- public override void Dispose ( )
121+
122+ public void Dispose ( )
109123 {
110124 Dispose ( true ) ;
111125 GC . SuppressFinalize ( this ) ;
@@ -125,8 +139,8 @@ protected virtual void Dispose(bool disposing)
125139 disposed = true ;
126140 }
127141 }
128-
129- ~ OutOfProcessNodeRunner ( ) {
142+
143+ ~ OutOfProcessNodeInstance ( ) {
130144 Dispose ( false ) ;
131145 }
132146 }
0 commit comments