当前位置: 首页>>代码示例>>Golang>>正文


Golang bindings.GetAsyncWaiter函数代码示例

本文整理汇总了Golang中mojo/public/go/bindings.GetAsyncWaiter函数的典型用法代码示例。如果您正苦于以下问题:Golang GetAsyncWaiter函数的具体用法?Golang GetAsyncWaiter怎么用?Golang GetAsyncWaiter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetAsyncWaiter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Initialize

func (d *HttpHandlerDelegate) Initialize(ctx application.Context) {
	request, pointer := http_server_factory.CreateMessagePipeForHttpServerFactory()
	ctx.ConnectToApplication("mojo:http_server").ConnectToService(&request)
	factory := http_server_factory.NewHttpServerFactoryProxy(pointer, bindings.GetAsyncWaiter())

	addr := &net_address.NetAddress{
		net_address.NetAddressFamily_IpV4,
		&net_address.NetAddressIPv4{
			8080,
			[4]uint8{127, 0, 0, 1},
		},
		nil,
	}
	serverRequest, serverPointer := http_server.CreateMessagePipeForHttpServer()
	factory.CreateHttpServer(serverRequest, addr)
	d.server = http_server.NewHttpServerProxy(serverPointer, bindings.GetAsyncWaiter())
	handlerRequest, handlerPointer := http_server.CreateMessagePipeForHttpHandler()
	ok, err := d.server.SetHandler("/go", handlerPointer)
	if !ok {
		log.Println("can't set handler:", err)
		return
	}

	d.handlerStub = http_server.NewHttpHandlerStub(handlerRequest, &HttpHandler{}, bindings.GetAsyncWaiter())
	go func() {
		for {
			if err := d.handlerStub.ServeRequest(); err != nil {
				log.Println("can't handle http request:", err)
				return
			}
		}
	}()
	factory.Close_Proxy()
}
开发者ID:Miaque,项目名称:mojo,代码行数:34,代码来源:http_handler.go

示例2: Scan

func (d *mdiscovery) Scan(query string, handlerPtr mojom.ScanHandler_Pointer) (*mojom.Closer_Pointer, *mojom.Error, error) {
	ctx, cancel := context.WithCancel(d.ctx)

	scanCh, err := d.d.Scan(ctx, query)
	if err != nil {
		cancel()
		return nil, v2mError(err), nil
	}

	handler := mojom.NewScanHandlerProxy(handlerPtr, bindings.GetAsyncWaiter())
	go func() {
		defer handler.Close_Proxy()

		for update := range scanCh {
			mUpdate := newMojoUpdate(d.ctx, update)

			req, ptr := mojom.CreateMessagePipeForUpdate()
			stub := mojom.NewUpdateStub(req, mUpdate, bindings.GetAsyncWaiter())
			if err := handler.OnUpdate(ptr); err != nil {
				stub.Close()
				cancel()
				return
			}
			d.serveStub(stub, nil)
		}
	}()

	req, ptr := mojom.CreateMessagePipeForCloser()
	stub := mojom.NewCloserStub(req, &closer{cancel}, bindings.GetAsyncWaiter())
	d.serveStub(stub, cancel)
	return &ptr, nil, nil
}
开发者ID:vanadium,项目名称:mojo.discovery,代码行数:32,代码来源:discovery.go

示例3: fetchWireBlessings

func (psd *principalServiceDelegate) fetchWireBlessings(token string, pub publicKey) (*wireBlessings, error) {
	networkReq, networkPtr := network.CreateMessagePipeForNetworkService()
	psd.Ctx.ConnectToApplication("mojo:network_service").ConnectToService(&networkReq)
	networkProxy := network.NewNetworkServiceProxy(networkPtr, bindings.GetAsyncWaiter())

	urlLoaderReq, urlLoaderPtr := url_loader.CreateMessagePipeForUrlLoader()
	if err := networkProxy.CreateUrlLoader(urlLoaderReq); err != nil {
		return nil, fmt.Errorf("Failed to create url loader: %v", err)
	}
	urlLoaderProxy := url_loader.NewUrlLoaderProxy(urlLoaderPtr, bindings.GetAsyncWaiter())

	req, err := blessingRequestURL(token, pub)
	if err != nil {
		return nil, err
	}

	resp, err := urlLoaderProxy.Start(*req)
	if err != nil || resp.Error != nil {
		return nil, fmt.Errorf("Blessings request to Vanadium Identity Provider failed: %v(%v)", err, resp.Error)
	}

	res, b := (*resp.Body).ReadData(system.MOJO_READ_DATA_FLAG_ALL_OR_NONE)
	if res != system.MOJO_RESULT_OK {
		return nil, fmt.Errorf("Failed to read response (blessings) from Vanadium Identity Provider. Result: %v", res)
	}

	var wb wireBlessings
	if err := json.Unmarshal(b, &wb); err != nil {
		return nil, fmt.Errorf("Failed to unmarshal response (blessings) from Vanadium Identity Provider: %v", err)
	}
	// TODO(ataly, gauthamt): We should verify all signatures on the certificate chains in the
	// wire blessings to ensure that it was not tampered with.
	return &wb, nil
}
开发者ID:ukode,项目名称:mojo,代码行数:34,代码来源:principal_service.go

示例4: Initialize

func (d *delegate) Initialize(ctx application.Context) {
	req, ptr := discovery.CreateMessagePipeForDiscovery()
	ctx.ConnectToApplication("https://mojo.v.io/discovery.mojo").ConnectToService(&req)

	ad := discovery.Advertisement{
		InterfaceName: "v.io/discovery.T",
		Addresses:     []string{"localhost:1000"},
		Attributes:    &map[string]string{"foo": "abc"},
		Attachments:   &map[string][]byte{"bar": []byte{1, 2, 3}},
	}
	dProxy := discovery.NewDiscoveryProxy(ptr, bindings.GetAsyncWaiter())
	id, closerPtr, e1, e2 := dProxy.Advertise(ad, nil)
	if e1 != nil || e2 != nil {
		log.Printf("Failed to advertise: %v, %v", e1, e2)
		return
	}
	log.Printf("Advertising %x...", *id)

	d.stop = func() {
		cProxy := discovery.NewCloserProxy(*closerPtr, bindings.GetAsyncWaiter())
		cProxy.Close()
		cProxy.Close_Proxy()

		dProxy.Close_Proxy()
	}
}
开发者ID:vanadium,项目名称:mojo.discovery,代码行数:26,代码来源:advertiser.go

示例5: getBlessing

func (psd *principalServiceDelegate) getBlessing(token string, pub publicKey) ([]uint8, error) {
	networkReq, networkPtr := network.CreateMessagePipeForNetworkService()
	psd.Ctx.ConnectToApplication("mojo:network_service").ConnectToService(&networkReq)
	networkProxy := network.NewNetworkServiceProxy(networkPtr, bindings.GetAsyncWaiter())

	urlLoaderReq, urlLoaderPtr := url_loader.CreateMessagePipeForUrlLoader()
	if err := networkProxy.CreateUrlLoader(urlLoaderReq); err != nil {
		return nil, fmt.Errorf("failed to create url loader: %v", err)
	}
	urlLoader := url_loader.NewUrlLoaderProxy(urlLoaderPtr, bindings.GetAsyncWaiter())

	req, err := blessingRequestURL(token, pub)
	if err != nil {
		return nil, err
	}

	resp, err := urlLoader.Start(*req)
	if err != nil || resp.Error != nil {
		return nil, fmt.Errorf("blessings request to Vanadium Identity Provider failed: %v(%v)", err, resp.Error)
	}

	res, b := (*resp.Body).ReadData(system.MOJO_READ_DATA_FLAG_ALL_OR_NONE)
	if res != system.MOJO_RESULT_OK {
		return nil, fmt.Errorf("failed to read response (blessings) from Vanadium Identity Provider. Result: %v", res)
	}
	return b, nil
}
开发者ID:willbittner,项目名称:mojo,代码行数:27,代码来源:principal_service.go

示例6: callRemoteSignature

// callRemoteSignature obtains type and header information from the remote
// mojo service. Remote mojo interfaces all define a signature method.
func (fs fakeService) callRemoteSignature(mojourl string, mojoname string) (mojomInterface mojom_types.MojomInterface, desc map[string]mojom_types.UserDefinedType, err error) {
	// TODO(afandria): The service_describer mojom file defines the constant, but
	// it is not actually present in the generated code:
	// https://github.com/domokit/mojo/issues/469
	// serviceDescriberInterfaceName := "_ServiceDescriber"

	r, p := service_describer.CreateMessagePipeForServiceDescriber()
	fs.appctx.ConnectToApplication(mojourl).ConnectToService(&r)
	sDescriber := service_describer.NewServiceDescriberProxy(p, bindings.GetAsyncWaiter())
	defer sDescriber.Close_Proxy()

	r2, p2 := service_describer.CreateMessagePipeForServiceDescription()
	err = sDescriber.DescribeService(mojoname, r2)
	if err != nil {
		return
	}
	sDescription := service_describer.NewServiceDescriptionProxy(p2, bindings.GetAsyncWaiter())
	defer sDescription.Close_Proxy()

	mojomInterface, err = sDescription.GetTopLevelInterface()
	if err != nil {
		return
	}
	descPtr, err := sDescription.GetAllTypeDefinitions()
	if err != nil {
		return
	}
	return mojomInterface, *descPtr, nil
}
开发者ID:vanadium,项目名称:mojo.v23proxy,代码行数:31,代码来源:serverproxy.go

示例7: Initialize

// When running fortune_client, ctx.Args() should contain:
// 0: mojo app name
// 1: remote endpoint
// 2+: (optional) fortune to add
// If the fortune to add is omitted, then the fortune_client will Get a fortune.
// Otherwise, it will Add the given fortune.
func (delegate *FortuneClientDelegate) Initialize(ctx application.Context) {
	// Parse the arguments.
	remoteEndpoint := ctx.Args()[1]
	addFortune := strings.Join(ctx.Args()[2:], " ")

	log.Printf("FortuneClientDelegate.Initialize... %s", remoteEndpoint)
	fortuneRequest, fortunePointer := fortune.CreateMessagePipeForFortune()
	v23.ConnectToRemoteService(ctx, &fortuneRequest, remoteEndpoint)
	fortuneProxy := fortune.NewFortuneProxy(fortunePointer, bindings.GetAsyncWaiter())

	if addFortune != "" {
		log.Printf("FortuneClientDelegate.Initialize calling Add...")

		if err := fortuneProxy.Add(addFortune); err != nil {
			log.Println(err)
		} else {
			fmt.Printf("client added: %s\n", addFortune)
		}
	} else {
		log.Printf("FortuneClientDelegate.Initialize calling Get...")
		response, err := fortuneProxy.Get()
		if response != "" {
			fmt.Printf("client (get): %s\n", response)
		} else {
			log.Println(err)
		}
	}

	fortuneProxy.Close_Proxy()
	ctx.Close()
}
开发者ID:vanadium,项目名称:mojo.v23proxy,代码行数:37,代码来源:fortune_client.go

示例8: match

func match(updatePtrs []mojom.Update_Pointer, lost bool, wants ...mojom.Advertisement) error {
	updateMap := make(map[[internal.AdIdLen]uint8]mojom.Update)
	updates := make([]mojom.Update, 0)
	for _, ptr := range updatePtrs {
		update := mojom.NewUpdateProxy(ptr, bindings.GetAsyncWaiter())
		defer update.Close_Proxy()

		id, _ := update.GetId()
		updateMap[id] = update
		updates = append(updates, update)
	}
	for _, want := range wants {
		update := updateMap[*want.Id]
		if update == nil {
			break
		}
		if got, _ := update.IsLost(); got != lost {
			break
		}
		if !updateEqual(update, want) {
			break
		}
		delete(updateMap, *want.Id)
	}
	if len(updateMap) == 0 {
		return nil
	}
	return fmt.Errorf("Match failed; got %v, but wanted %v", updatesToDebugString(updates), adsToDebugString(wants))
}
开发者ID:vanadium,项目名称:mojo.discovery,代码行数:29,代码来源:apptest_util.go

示例9: SetupClientProxy

func (r *v23HeaderReceiver) SetupClientProxy(v23Name string, ifaceSig mojom_types.MojomInterface, desc map[string]mojom_types.UserDefinedType, serviceName string, handle system.MessagePipeHandle) (err error) {
	log := r.delegate.ctx
	log.Infof("[server] In SetupProxy(%s, %v, %v, %s, %v)", v23Name, ifaceSig, desc, serviceName, handle)
	r.v23Name = v23Name
	r.ifaceSig = ifaceSig
	r.desc = desc
	r.serviceName = serviceName
	r.handle = handle

	go func() {
		connector := bindings.NewConnector(r.handle, bindings.GetAsyncWaiter())

		// Read generic calls in a loop
		receiver := &messageReceiver{
			header:    r,
			ctx:       r.delegate.ctx,
			connector: connector,
		}
		stub := bindings.NewStub(connector, receiver)
		for {
			if err := stub.ServeRequest(); err != nil {
				connectionError, ok := err.(*bindings.ConnectionError)
				if !ok || !connectionError.Closed() {
					log.Errorf("%v", err)
				}
				break
			}
		}
		r.delegate.stubs = append(r.delegate.stubs, stub)
	}()
	return nil
}
开发者ID:vanadium,项目名称:mojo.v23proxy,代码行数:32,代码来源:clientproxy.go

示例10: ProvideServices

// ProvideServices starts a service provider on a separate goroutine that
// provides given services to the remote application. Returns a pointer to
// outgoing connection that can be used to connect to services provided by
// remote application.
// Panics if called more than once.
func (c *Connection) ProvideServices(services ...ServiceFactory) *OutgoingConnection {
	if c.servicesProvided {
		panic("ProvideServices or ProvideServicesWithDescriber can be called only once")
	}
	c.servicesProvided = true
	if c.servicesRequest == nil {
		return c.outgoingConnection
	}
	if len(services) == 0 {
		c.servicesRequest.PassMessagePipe().Close()
		return c.outgoingConnection
	}

	provider := &serviceProviderImpl{
		make(map[string]ServiceFactory),
	}
	for _, service := range services {
		provider.AddService(service)
	}
	c.localServices = sp.NewServiceProviderStub(*c.servicesRequest, provider, bindings.GetAsyncWaiter())
	go func() {
		for {
			if err := c.localServices.ServeRequest(); err != nil {
				connectionError, ok := err.(*bindings.ConnectionError)
				if !ok || !connectionError.Closed() {
					log.Println(err)
				}
				break
			}
		}
	}()
	return c.outgoingConnection
}
开发者ID:willbittner,项目名称:mojo,代码行数:38,代码来源:connection.go

示例11: Initialize

// When running echo_client, ctx.Args() should contain:
// 0: mojo app name
// 1: remote endpoint
// 2+: string to echo
func (delegate *RemoteEchoClientDelegate) Initialize(ctx application.Context) {
	log.Printf("RemoteEchoClientDelegate.Initialize...")

	// Parse arguments. Note: May panic if not enough args are given.
	remoteEndpoint := ctx.Args()[1]
	echoString := "Hello, Go world!"
	if len(ctx.Args()) > 2 {
		echoString = strings.Join(ctx.Args()[2:], " ")
	}

	r, p := echo.CreateMessagePipeForRemoteEcho()

	v23.ConnectToRemoteService(ctx, &r, remoteEndpoint)
	echoProxy := echo.NewRemoteEchoProxy(p, bindings.GetAsyncWaiter())

	log.Printf("RemoteEchoClientDelegate.Initialize calling EchoString...")
	response, err := echoProxy.EchoString(echoString)
	if err == nil {
		fmt.Printf("client: %s\n", response)
	} else {
		fmt.Printf("error: %v\n", err)
	}

	log.Printf("RemoteEchoClientDelegate.Initialize calling EchoX...")
	response2, err := echoProxy.EchoX([]bool{true, false, false, true}, echo.AInArg{"A String"})
	if err == nil {
		fmt.Printf("client: %v\n", response2)
	} else {
		log.Println("Error: ", err)
	}

	fmt.Printf("(done)\n")
	echoProxy.Close_Proxy()
	ctx.Close()
}
开发者ID:vanadium,项目名称:mojo.v23proxy,代码行数:39,代码来源:echo_client.go

示例12: createProxy

func createProxy(ctx application.Context) *end_to_end_test.V23ProxyTest_Proxy {
	// Parse arguments. Note: May panic if not enough args are given.
	remoteName := *endpointFlag

	r, p := end_to_end_test.CreateMessagePipeForV23ProxyTest()
	v23.ConnectToRemoteService(ctx, &r, remoteName)
	return end_to_end_test.NewV23ProxyTestProxy(p, bindings.GetAsyncWaiter())
}
开发者ID:vanadium,项目名称:mojo.v23proxy,代码行数:8,代码来源:test_client.go

示例13: Initialize

// Mojo application implementation.
func (impl *ApplicationImpl) Initialize(shellPointer shell.Shell_Pointer, args *[]string, url string) error {
	impl.shell = shell.NewShellProxy(shellPointer, bindings.GetAsyncWaiter())
	if args != nil {
		impl.args = *args
	}
	impl.url = url
	impl.delegate.Initialize(impl)
	return nil
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:10,代码来源:application_impl.go

示例14: Create

func (f *factory) Create(request mojom.Discovery_Request) {
	discovery, err := internal.NewDiscovery(f.d.ctx, f.url)
	if err != nil {
		f.d.ctx.Error(err)
		request.Close()
		return
	}
	stub := mojom.NewDiscoveryStub(request, discovery, bindings.GetAsyncWaiter())
	f.d.run(stub, discovery.Close)
}
开发者ID:vanadium,项目名称:mojo.discovery,代码行数:10,代码来源:discovery.go

示例15: Create

func (delegate *EchoDelegate) Create(request echo.Echo_Request) {
	stub := echo.NewEchoStub(request, &EchoImpl{}, bindings.GetAsyncWaiter())
	go func() {
		if err := stub.ServeRequest(); err != nil {
			panic(err)
		}
		stub.Close()
		delegate.Wg.Done()
	}()
}
开发者ID:willbittner,项目名称:mojo,代码行数:10,代码来源:application_impl_test.go


注:本文中的mojo/public/go/bindings.GetAsyncWaiter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。