4 Commits

Author SHA1 Message Date
9b32682c8a libnmdc: support hub-redirects 2016-04-04 19:01:55 +12:00
c9e95df0df libnmdc: fix for previous 2016-04-04 19:01:47 +12:00
a2b94e8724 libnmdc: send protocol-level keepalives 2016-04-04 18:57:50 +12:00
3dfef302ee Added tag nmdc-log-service-1.0.2 for changeset da9f123633f9 2016-04-03 19:24:12 +12:00
2 changed files with 17 additions and 7 deletions

View File

@@ -4,3 +4,4 @@
d8b64d5527c2a5e4d76872e5bc3d69f7646135c6 libnmdc-r3 d8b64d5527c2a5e4d76872e5bc3d69f7646135c6 libnmdc-r3
fca41372e400853775b02e951f9db91d87f41adb nmdc-log-service-1.0.1 fca41372e400853775b02e951f9db91d87f41adb nmdc-log-service-1.0.1
050b424a7c5d5a27c9323c8810f3afbead1f5b96 libnmdc-r4 050b424a7c5d5a27c9323c8810f3afbead1f5b96 libnmdc-r4
da9f123633f9c28be6435ed7898139665d4c39d9 nmdc-log-service-1.0.2

View File

@@ -15,6 +15,7 @@ import (
const ( const (
DEFAULT_CLIENT_TAG string = "libnmdc.go" DEFAULT_CLIENT_TAG string = "libnmdc.go"
DEFAULT_HUB_NAME string = "(unknown)" DEFAULT_HUB_NAME string = "(unknown)"
SEND_KEEPALIVE_EVERY time.Duration = 29 * time.Second
) )
type ConnectionState int type ConnectionState int
@@ -314,15 +315,13 @@ func (this *HubConnection) processProtocolMessage(message string) {
this.State = CONNECTIONSTATE_CONNECTED this.State = CONNECTIONSTATE_CONNECTED
} }
case "$UserCommand":
// $UserCommand 1 1 Group chat\New group chat$<%[mynick]> !groupchat_new&#124;|
// TODO
case "$ForceMove": case "$ForceMove":
// TODO this.Hco.Address = HubAddress(commandParts[1])
this.conn.Close() // we'll reconnect onto the new address
// IGNORABLE COMMANDS // IGNORABLE COMMANDS
case "$Supports": case "$Supports":
case "$UserCommand": // TODO $UserCommand 1 1 Group chat\New group chat$<%[mynick]> !groupchat_new&#124;|
case "$UserList": case "$UserList":
case "$OpList": case "$OpList":
case "$HubTopic": case "$HubTopic":
@@ -370,7 +369,17 @@ func (this *HubConnection) worker() {
// Read from socket into our local buffer (blocking) // Read from socket into our local buffer (blocking)
if this.connValid { if this.connValid {
readBuff := make([]byte, 1024) readBuff := make([]byte, 1024)
this.conn.SetReadDeadline(time.Now().Add(SEND_KEEPALIVE_EVERY))
nbytes, err = this.conn.Read(readBuff) nbytes, err = this.conn.Read(readBuff)
if err != nil && err.(net.Error).Timeout() {
// No data before read deadline
err = nil
// Send KA packet
_, err = this.conn.Write([]byte("|"))
}
if nbytes > 0 { if nbytes > 0 {
fullBuffer += string(readBuff[0:nbytes]) fullBuffer += string(readBuff[0:nbytes])
} }