Skip to content

[BUG] The Message.FromStackExchange field do not perform as expected when using StackExchange #56

Open
@bigBron

Description

In my case fromStackExchange is always false:

const waitComesFromStackExchange = '!'
var wait = "1620719461266218800"
fmt.Printf("waitComesFromStackExchange=%s wait=%s\n", string(waitComesFromStackExchange), wait)

//wait[0]: type = uint8
//waitComesFromStackExchange: type = int32
//string(wait[0]+waitComesFromStackExchange) = 'R'

//await := genWaitStackExchange(wait) // R620719461266218800
fmt.Printf("genWaitStackExchange(wait) = %s\n", string(wait[0]+waitComesFromStackExchange)+wait[1:])

//fromStackExchange = false
var await = "R620719461266218800"
fromStackExchange := len(await) > 2 && await[1] == waitComesFromStackExchange
fmt.Printf("fromStackExchange = %v\n", fromStackExchange)

neffos/message.go

Lines 237 to 246 in 2221a9a

func genWaitStackExchange(wait string) string {
if len(wait) < 2 {
return ""
}
// This is the second special character.
// If found, it is removed on the deserialization
// and Message.FromStackExchange is set to true.
return string(wait[0]+waitComesFromStackExchange) + wait[1:]
}

neffos/message.go

Lines 349 to 375 in 2221a9a

fromStackExchange := len(wait) > 2 && wait[1] == waitComesFromStackExchange
if fromStackExchange {
// remove the second special char, we need to reform it,
// this wait token is compared to the waiter side as it's without the information about stackexchnage.
wait = string(wait[0]) + wait[2:]
}
return Message{
wait: wait,
Namespace: unescape(namespace),
Room: unescape(room),
Event: unescape(event),
Body: body,
Err: err,
isError: err != nil,
isNoOp: isNoOp,
isInvalid: isInvalid,
from: "",
FromExplicit: fromExplicit,
FromStackExchange: fromStackExchange,
To: "",
IsForced: false,
IsLocal: false,
IsNative: allowNativeMessages && event == OnNativeMessage,
locked: false,
SetBinary: msgTyp == BinaryMessage,
}

neffos/conn.go

Lines 428 to 432 in 2221a9a

if msg.FromStackExchange && c.server.usesStackExchange() {
// Currently let's not export the wait field, instead
// just accept it on the stackexchange.
return c.server.StackExchange.NotifyAsk(msg, msg.wait)
}

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions