|
|
@ -50,12 +50,11 @@ type client struct { |
|
|
|
Codec |
|
|
|
Codec |
|
|
|
ChannellingAPI |
|
|
|
ChannellingAPI |
|
|
|
Connection |
|
|
|
Connection |
|
|
|
session *Session |
|
|
|
session *Session |
|
|
|
replaced bool |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func NewClient(codec Codec, api ChannellingAPI, session *Session) *client { |
|
|
|
func NewClient(codec Codec, api ChannellingAPI, session *Session) *client { |
|
|
|
return &client{codec, api, nil, session, false} |
|
|
|
return &client{codec, api, nil, session} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (client *client) OnConnect(conn Connection) { |
|
|
|
func (client *client) OnConnect(conn Connection) { |
|
|
@ -65,11 +64,7 @@ func (client *client) OnConnect(conn Connection) { |
|
|
|
|
|
|
|
|
|
|
|
func (client *client) OnDisconnect() { |
|
|
|
func (client *client) OnDisconnect() { |
|
|
|
client.session.Close() |
|
|
|
client.session.Close() |
|
|
|
if client.replaced { |
|
|
|
client.ChannellingAPI.OnDisconnect(client, client.session) |
|
|
|
log.Printf("Not cleaning up session %s as client %d was replaced\n", client.session.Id, client.Index()) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
client.ChannellingAPI.OnDisconnect(client.session.Id) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (client *client) OnText(b Buffer) { |
|
|
|
func (client *client) OnText(b Buffer) { |
|
|
@ -94,7 +89,6 @@ func (client *client) Session() *Session { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (client *client) ReplaceAndClose() { |
|
|
|
func (client *client) ReplaceAndClose() { |
|
|
|
client.replaced = true |
|
|
|
|
|
|
|
client.session.Close() |
|
|
|
client.session.Close() |
|
|
|
if client.Connection != nil { |
|
|
|
if client.Connection != nil { |
|
|
|
client.Connection.Close() |
|
|
|
client.Connection.Close() |
|
|
|