//在LoginServer创建虚拟用户
func setSessionOnline(session *link.Session, protoMsg protos.ProtoMsg) {
	rev_msg := protoMsg.Body.(*systemProto.System_ClientSessionOnlineC2S)
	userConn := proxys.NewDummyConn(rev_msg.GetSessionID(), rev_msg.GetNetwork(), rev_msg.GetAddr(), transferClient)
	userSession := link.NewSessionByID(userConn, codecType.DummyCodecType{}, rev_msg.GetSessionID())
	userSession.State = make(chan []byte, 100)
	userSession.AddCloseCallback(userSession, func() { close(userSession.State.(chan []byte)) })
	global.AddSession(userSession)
	//接收游戏消息
	go func() {
		var msg []byte
		for {
			if err := userSession.Receive(&msg); err != nil {
				break
			}
			gameProxy.MsgDispatch.Process(userSession, msg)
		}
	}()
	//接收DB消息
	go func() {
		dbMsgChan := userSession.State.(chan []byte)
		for {
			data, ok := <-dbMsgChan
			if !ok {
				return
			}
			dbProxy.ClientDbMsgDispatchHandle.DealMsg(userSession, data)
		}
	}()
}
예제 #2
0
//在World服务器设置用户登录成功
func setClientLoginSuccess(session *link.Session, protoMsg protos.ProtoMsg) {
	rev_msg := protoMsg.Body.(*systemProto.System_ClientLoginSuccessC2S)
	userConn := proxys.NewDummyConn(rev_msg.GetSessionID(), rev_msg.GetNetwork(), rev_msg.GetAddr(), session)
	userSession := link.NewSessionByID(userConn, codecType.DummyCodecType{}, rev_msg.GetSessionID())
	global.AddSession(userSession)
	go func() {
		var msg []byte
		for {
			if err := userSession.Receive(&msg); err != nil {
				break
			}
			gameProxy.MsgDispatch.Process(userSession, msg)
		}
	}()
	module.User.LoginSuccess(userSession, rev_msg.GetUserName(), rev_msg.GetUserID(), rev_msg.GetGameServerID())
}