Handle UserState and UserRemove (with a few exceptions!)

This commit is contained in:
Mikkel Krautz 2010-11-27 14:22:47 +01:00
parent 4903558e4a
commit 925e23b0f9
4 changed files with 235 additions and 28 deletions

View file

@ -37,12 +37,21 @@ type Client struct {
udp bool
// Personal
UserId int
Session uint32
Username string
Hash string
Tokens []string
Channel *Channel
UserId int
Session uint32
Username string
Hash string
Tokens []string
Channel *Channel
SelfMute bool
SelfDeaf bool
Mute bool
Deaf bool
Suppress bool
PrioritySpeaker bool
Recording bool
PluginContext []byte
PluginIdentity string
}
// Something invalid happened on the wire.
@ -51,18 +60,28 @@ func (client *Client) Panic(reason string) {
client.Disconnect()
}
func (client *Client) Disconnect() {
// Internal disconnect function
func (client *Client) disconnect(kicked bool) {
if !client.disconnected {
client.disconnected = true
close(client.udprecv)
close(client.msgchan)
client.conn.Close()
client.server.RemoveClient(client)
client.server.RemoveClient(client, kicked)
}
}
// Disconnect a client (client disconnected)
func (client *Client) Disconnect() {
client.disconnect(false)
}
// Disconnect a client (kick/ban)
func (client *Client) ForceDisconnect() {
client.disconnect(true)
}
// Read a protobuf message from a client
func (client *Client) readProtoMessage() (msg *Message, err os.Error) {
var length uint32