// Initialize connects to other instance, providing and asking for echo service. func (delegate *EchoDelegate) Initialize(ctx application.Context) { if ctx.URL() != delegate.localURL { panic(fmt.Sprintf("invalid URL: want %v, got %v", delegate.localURL, ctx.URL())) } if len(ctx.Args()) != 1 || ctx.Args()[0] != delegate.localURL { panic(fmt.Sprintf("invalid args: want %v, got %v", []string{delegate.localURL}, ctx.Args())) } go func() { echoRequest, echoPointer := echo.CreateMessagePipeForEcho() conn := ctx.ConnectToApplication(pairedURL(delegate.localURL), &echo.Echo_ServiceFactory{delegate}) if conn.RequestorURL() != delegate.localURL { panic(fmt.Sprintf("invalid requestor URL: want %v, got %v", delegate.localURL, conn.RequestorURL())) } if conn.ConnectionURL() != pairedURL(delegate.localURL) { panic(fmt.Sprintf("invalid connection URL: want %v, got %v", pairedURL(delegate.localURL), conn.ConnectionURL())) } conn.ConnectToService(&echoRequest) checkEcho(echoPointer) }() }