Esempio n. 1
0
func RegisterServer(server *protocols.Server, handler Handler) error {
	if err := server.Protocol().CheckIncludesFragment(Protocol.Name()); err != nil {
		return err
	}
	state := &serverState{
		Server:  server,
		handler: handler,
	}
	if err := server.RegisterHandlers(protocols.ServerHandlerMap{
		CodeRedirectStream: state.handleRedirectStream,
		CodePauseStream:    state.handlePauseStream,
		CodeResumeStream:   state.handleResumeStream,
	}); err != nil {
		return err
	}
	server.RegisterStopHandler(state.stopServer)
	return nil
}
Esempio n. 2
0
func RegisterServer(server *protocols.Server, handler Handler) error {
	if err := server.Protocol().CheckIncludesFragment(Protocol.Name()); err != nil {
		return err
	}
	state := &serverState{
		Server:  server,
		handler: handler,
	}
	if err := server.RegisterHandlers(protocols.ServerHandlerMap{
		codeStartProxy:     state.handleStartProxy,
		codeStopProxy:      state.handleStopProxy,
		codeStartProxyPair: state.handleStartProxyPair,
		codeStopProxyPair:  state.handleStopProxyPair,
	}); err != nil {
		return err
	}
	server.RegisterStopHandler(state.stopServer)
	return nil
}