Make LastChannel logic work.

This commit is contained in:
Mikkel Krautz 2011-11-12 21:36:32 +01:00
parent 41689595f2
commit b1d6717a04
3 changed files with 14 additions and 5 deletions

View file

@ -691,9 +691,10 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
} }
// Update the datastore with the user's current state. // Update the datastore with the user's current state.
func (server *Server) UpdateFrozenUser(user *User, state *mumbleproto.UserState) { func (server *Server) UpdateFrozenUser(client *Client, state *mumbleproto.UserState) {
// Full sync If there's no userstate messgae provided, or if there is one, and // Full sync If there's no userstate messgae provided, or if there is one, and
// it includes a registration operation. // it includes a registration operation.
user := client.user
nanos := time.Nanoseconds() nanos := time.Nanoseconds()
if state == nil || state.UserId != nil { if state == nil || state.UserId != nil {
fu, err := user.Freeze() fu, err := user.Freeze()
@ -709,7 +710,7 @@ func (server *Server) UpdateFrozenUser(user *User, state *mumbleproto.UserState)
fu := &freezer.User{} fu := &freezer.User{}
fu.Id = proto.Uint32(user.Id) fu.Id = proto.Uint32(user.Id)
if state.ChannelId != nil { if state.ChannelId != nil {
fu.LastChannelId = state.ChannelId fu.LastChannelId = proto.Uint32(uint32(client.Channel.Id))
} }
if state.TextureHash != nil { if state.TextureHash != nil {
fu.TextureBlob = proto.String(user.TextureBlob) fu.TextureBlob = proto.String(user.TextureBlob)

View file

@ -874,7 +874,7 @@ func (server *Server) handleUserStateMessage(client *Client, msg *Message) {
} }
if target.IsRegistered() { if target.IsRegistered() {
server.UpdateFrozenUser(target.user, userstate) server.UpdateFrozenUser(target, userstate)
} }
} }

View file

@ -561,10 +561,18 @@ func (server *Server) finishAuthenticate(client *Client) {
server.hclients[host] = append(server.hclients[host], client) server.hclients[host] = append(server.hclients[host], client)
server.hmutex.Unlock() server.hmutex.Unlock()
channel := server.RootChannel()
if client.IsRegistered() {
lastChannel := server.Channels[client.user.LastChannelId]
if lastChannel != nil {
channel = lastChannel
}
}
userstate := &mumbleproto.UserState{ userstate := &mumbleproto.UserState{
Session: proto.Uint32(client.Session), Session: proto.Uint32(client.Session),
Name: proto.String(client.ShownName()), Name: proto.String(client.ShownName()),
ChannelId: proto.Uint32(0), ChannelId: proto.Uint32(uint32(channel.Id)),
} }
if len(client.CertHash) > 0 { if len(client.CertHash) > 0 {
@ -601,7 +609,7 @@ func (server *Server) finishAuthenticate(client *Client) {
} }
} }
server.userEnterChannel(client, server.RootChannel(), userstate) server.userEnterChannel(client, channel, userstate)
if err := server.broadcastProtoMessage(userstate); err != nil { if err := server.broadcastProtoMessage(userstate); err != nil {
// Server panic? // Server panic?
} }