func (srs *SessionRpcServer) Start() {
	ctx := context.GetContext()
	coRpcS, ok := ctx.GetComponent("corpcserver").(*corpcserver.CoRpcServer)

	if ok == false {
		coRpcS = corpcserver.NewCoRpcServer()
	}

	seelog.Infof("frontendserver<%v> SessionRpcServer start,registe service to rpc server", ctx.GetServerID())
	// srs := NewSessionRpcServer()
	coRpcS.RegisteService(srs)
}
func (crs *ChannelRpcServer) Start() {
	ctx := context.GetContext()
	coRpcS, ok := ctx.GetComponent("corpcserver").(*corpcserver.CoRpcServer)

	if ok == false {
		coRpcS = corpcserver.NewCoRpcServer()
	}

	seelog.Info("ChannelRpcServer start,registe service to rpcserver")
	// srs := NewSessionRpcServer()
	coRpcS.RegisteService(crs)

}
Esempio n. 3
0
func NewServer() *Server {
	ctx := context.GetContext()

	coRpcS, ok1 := ctx.GetComponent("corpcserver").(*corpcserver.CoRpcServer)
	if ok1 == false {
		coRpcS = corpcserver.NewCoRpcServer()
	}

	coRpcC, ok2 := ctx.GetComponent("corpcclient").(*corpcclient.CoRpcClient)
	if ok2 == false {
		coRpcC = corpcclient.NewCoRpcClient()
	}
	handlers := make(map[string]func(*sessionService.SimpleSession, map[string]interface{}) map[string]interface{})
	return &Server{ctx, coRpcS, coRpcC, handlers}
}
Esempio n. 4
0
func main() {
	ctx := context.GetContext()
	allOpts := make(map[string]map[string]interface{})
	cosessOpts := make(map[string]interface{})

	//指定同一个uid可以绑定多个session
	cosessOpts["multiBind"] = "yes"
	allOpts["cosession"] = cosessOpts
	ctx.AllOpts = allOpts
	defer seelog.Flush()
	currentServer := make(map[string]interface{})
	currentServer["id"] = "connector-1"
	currentServer["serverType"] = "connector"
	currentServer["host"] = "127.0.0.1"
	currentServer["port"] = 8888
	ctx.CurrentServer = currentServer
	cosess := cosession.NewCoSession()
	cosessRS := cosessionrpcserver.NewCoSessionRpcServer()
	corpcS := corpcserver.NewCoRpcServer()

	// 启动cosession,cosessionrpcserver,corpcserver
	cosess.Start()
	cosessRS.Start()
	corpcS.Start()

	cosess.CreateSession(1, "connector-1", nil)
	cosess.BindUID("Zhang San", 1)
	cosess.CreateSession(2, "connector-1", nil)
	cosess.BindUID("Li Si", 2)
	cosess.CreateSession(3, "connector-1", nil)
	cosess.BindUID("Li Si", 3)
	cosess.CreateSession(4, "connector-1", nil)
	cosess.BindUID("Wang Wu", 4)

	ch := make(chan int)
	<-ch
}