// When the REMOTE side receives a quote request over chat (maybe from // LOCAL side subscribing to T42.RFQ.QuoteInquiryStream), // REMOTE side calls T42.RFQ.SendQuoteResponse to send a // response back. // Server calls Bridge to send response over chat private void SendQuoteResponseMethodHandler( IServerMethod method, IMethodInvocationContext invocationContext, IInstance caller, IServerMethodResultBuilder resultBuilder, Action <IServerMethodResult> asyncResponseCallback, object cookie) { var args = invocationContext.Arguments.ToDictionary(cv => cv.Name, cv => cv); var quantity = args.ContainsKey("quantity") ? (double?)args.SafeGetDouble("quantity") : null; bridge_.SendQuoteInquiryResponse( new RfqQuoteInquiryResponse( RfqResponseType.Quote, args.TryGetString("responseMessage"), args["requestId"].Value.AsString, args["requestParty"].Value.AsString, args["counterParty"].Value.AsString, args.TryGetString("productName"), null, quantity, args.SafeGetDouble("price"))); asyncResponseCallback(resultBuilder.Build()); }
static void Main(string[] args) { Glue42 glue42 = null; var initializeOptions = new InitializeOptions() { ApplicationName = "Hello Glue42 Interop", InitializeTimeout = TimeSpan.FromSeconds(5) }; Glue42.InitializeGlue(initializeOptions) .ContinueWith((glue) => { //unable to register glue if (glue.Status == TaskStatus.Faulted) { Log("Unable to initialize Glue42"); return; } glue42 = glue.Result; // subscribe to interop connection status event glue42.Interop.ConnectionStatusChanged += InteropOnConnectionStatusChanged; // Register synchronous calling endpoint, called HelloGlue. // we could use the serverEndpoint returned by this method to later unregister it by calling glue.Interop.UnregisterEndpoint IServerMethod serverEndpoint = glue42.Interop.RegisterSynchronousEndpoint(mdb => mdb.SetMethodName("HelloGlue"), OnHelloWorldInvoked); Log($"Registered endpoint called {serverEndpoint.Definition.Name}"); Log("Initialized Glue."); }); string input; // start the main loop, take console inputs until '!q' is passed. // send each line as an invocation argument, if not empty while (!string.Equals(input = Console.ReadLine(), "!q", StringComparison.CurrentCultureIgnoreCase)) { if (glue42 == null) { return; } InteropSendOperation(glue42, input); } }
private static IServerMethodResult OnHelloWorldInvoked( IServerMethod method, IMethodInvocationContext invocationContext, IInstance caller, IServerMethodResultBuilder resultBuilder, object cookie) { Log($"{caller.ApplicationName} said hello with these arguments: {{{invocationContext.Arguments.AsString()}}}"); // let's simulate a problem on the implementation side if (++invocationIndex_ % 3 == 0) { throw new Exception("Oops! Something happened!"); } // return empty (void) result. return(resultBuilder.Build()); }
// When the REMOTE side receives a comment from LOCAL side over chat // (maybe by LOCAL side calling T42.RFQ.SendCommentToCounterParty) // Server sends comment using Bridge, and // on the REMOTE side Server pushes comment to T42.RFQ.RequestPartyCommentStream // When the REMOTE side replies back by calling T42.RFQ.SendCommentToRequestParty // Server calls Bridge to send comment back over the chat and // on the LOCAL side pushes comment to T42.RFQ.CounterPartyCommentStream private void SendCommentToRequestPartyMethodHandler( IServerMethod method, IMethodInvocationContext invocationContext, IInstance caller, IServerMethodResultBuilder resultBuilder, Action <IServerMethodResult> asyncResponseCallback, object cookie) { var args = invocationContext.Arguments.ToDictionary(cv => cv.Name, cv => cv); bridge_.SendCommentToRequestParty( new RfqComment( args.TryGetString("requestId"), args["requestParty"].Value.AsString, args["counterParty"].Value.AsString, args.TryGetString("productName"), args["comment"].Value.AsString)); asyncResponseCallback(resultBuilder.Build()); }