| // Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| "mojo/public/go/application" |
| "mojo/public/go/bindings" |
| //#include "mojo/public/c/system/handle.h" |
| //#include "mojo/public/c/system/result.h" |
| type EchoClientDelegate struct{} |
| func (delegate *EchoClientDelegate) Initialize(ctx application.Context) { |
| echoRequest, echoPointer := echo.CreateMessagePipeForEcho() |
| ctx.ConnectToApplication("mojo:go_echo_server").ConnectToService(&echoRequest) |
| echoProxy := echo.NewEchoProxy(echoPointer, bindings.GetAsyncWaiter()) |
| response, err := echoProxy.EchoString(bindings.StringPointer("Hello, Go world!")) |
| fmt.Printf("client: %s\n", *response) |
| func (delegate *EchoClientDelegate) AcceptConnection(connection *application.Connection) { |
| func (delegate *EchoClientDelegate) Quit() { |
| func MojoMain(handle C.MojoHandle) C.MojoResult { |
| application.Run(&EchoClientDelegate{}, system.MojoHandle(handle)) |