コード例 #1
0
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&FortuneServerDelegate{
		fortuneFactory: FortuneFactory{
			fortune: NewFortuneImpl(),
		},
	}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
コード例 #2
0
func TestApplication(t *testing.T) {
	var apps []*mojoApp.Application_Proxy
	var responsesSent, appsTerminated sync.WaitGroup
	// Create and run applications.
	for i := 0; i < 2; i++ {
		request, pointer := mojoApp.CreateMessagePipeForApplication()
		apps = append(apps, mojoApp.NewApplicationProxy(pointer, bindings.GetAsyncWaiter()))
		// Each app instance provides echo service once when it creates
		// a connection and once other instance creates a connection.
		responsesSent.Add(2)
		appsTerminated.Add(1)
		delegate := &EchoDelegate{&responsesSent, urls[i]}
		go func() {
			application.Run(delegate, request.PassMessagePipe().ReleaseNativeHandle())
			appsTerminated.Done()
		}()
	}
	// Provide a shell for each application.
	for i := 0; i < 2; i++ {
		shellRequest, shellPointer := shell.CreateMessagePipeForShell()
		shellStub := shell.NewShellStub(shellRequest, &shellImpl{apps[i^1], urls[i]}, bindings.GetAsyncWaiter())
		go func() {
			if err := shellStub.ServeRequest(); err != nil {
				panic(err)
			}
			shellStub.Close()
		}()
		apps[i].Initialize(shellPointer, &[]string{urls[i]}, urls[i])
	}
	// Wait and then close pipes.
	responsesSent.Wait()
	for i := 0; i < 2; i++ {
		apps[i].RequestQuit()
	}
	appsTerminated.Wait()
	for i := 0; i < 2; i++ {
		apps[i].Close_Proxy()
	}
}
コード例 #3
0
ファイル: principal_service.go プロジェクト: ukode/mojo
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&principalServiceDelegate{}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
コード例 #4
0
ファイル: http_handler.go プロジェクト: Miaque/mojo
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&HttpHandlerDelegate{}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
コード例 #5
0
ファイル: test_server.go プロジェクト: vanadium/mojo.v23proxy
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&V23ProxyTestServerDelegate{}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
コード例 #6
0
ファイル: echo_client.go プロジェクト: vanadium/mojo.v23proxy
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&RemoteEchoClientDelegate{}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
コード例 #7
0
ファイル: discovery.go プロジェクト: vanadium/mojo.discovery
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&delegate{stubs: map[*bindings.Stub]struct{}{}}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}