Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bigBron opened this issue May 11, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@bigBron
Copy link

bigBron commented May 11, 2021

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)
}

@bigBron bigBron added the bug Something isn't working label May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants